Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kenny Burns 173 posts 305 karma points
    Dec 21, 2011 @ 18:11
    Kenny Burns
    0

    Memberships and Razor

    Hi Guys,

    Im trying out implementing a members area for the first time (awesome by the way!) and was wondering if anyone could help me out with this.

    <xsl:for-each select="$currentPage/node">
    <xsl:if test="umbraco.library:IsLoggedOn() and umbraco.library:HasAccess(@id, @path)">
    <xsl:value-of select="@nodeName"/>
    </xsl:if>
    </xsl:for-each>

    Basically I am trying to only list pages that you have access to and the above code seems to be a solution...but its in XSLT and I have my list pages already in Razor.

    I have been trying to convert the above into razor with something like:

    if(umbraco.library:IsLoggedOn() && umbraco.library;HasAccess(@id, @path)){

    //do something

    }

    ...but no luck. Am i on the right path?!

    Much appreciated

    Kenny

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 21, 2011 @ 18:17
    Jeroen Breuer
    0

    First of all in Razor you should use this syntax:

    umbraco.library.IsLoggedOn()

    And @id and @path won't work. Something like this might work:

    @if(umbraco.library.IsLoggedOn() && umbraco.library.HasAccess(Model.id, Model.path))

    Jeroen

  • Kenny Burns 173 posts 305 karma points
    Dec 21, 2011 @ 18:27
    Kenny Burns
    0

    Perfect Jeroen!

    It was my syntax that was wrong (will need to keep this in mind!)

    Thanks a lot for helping - i love this community - always sharing the love! :)

    Kenny

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 28, 2011 @ 19:59
    Sebastiaan Janssen
    0

    Also check out the cool Razor Login project for more membership inspiration and give Jonas a vote while you're at it! :-)

Please Sign in or register to post replies

Write your reply to:

Draft