Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 05, 2011 @ 16:47
    Dan
    0

    umbraco.library:IsLoggedOn as particular membergroup

    Hi,

    I have a small web app which lets users download documents if they're logged in.  It renders the items in XSLT and only shows them using an <xslt:if> like this:

    <xsl:if test="umbraco.library:IsLoggedOn()">
    <a href="document.pdf">Document to download</a>
    </xsl:if>

    However, ideally it should only apply to those members who are part of the member group 'testmembergroup'.  Can this be done with XSLT?  I'm struggling for references with umbraco.library.IsLoggedOn() as the wiki library is very patchy for some of these extensions.

    Thanks all

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 05, 2011 @ 18:41
    Jan Skovgaard
    0

    Hi Dan

    you can do this using a combination of umbraco.library:IsLoggedOn() and umbraco.library:HasAccess()

    To make the magic happen it's important that you on the pages, which only certain members should be able to access that you specifically setup the public access on that page to only this specific "testmembergroup".

    If you have a section like this...

    protected pages
     - protected page no 1
     - protected page no 2
     - protected page no 3
     - etc.

    Then you probably have set the public access on the root node (in this example protected pages) - and if alle the member groups you have can access this page it's inherited to the ancestors. Therefore you have to setup the access specifically on the page only one of the member groups must have access too.

    Once that is done you can write this in your XSLT to handle it.

    <xsl:if test="umbraco.library:IsLoggedOn() and umbraco.library:HasAccess($currentPage/@id,$currentPage/@path)">
    <!-- your code here -->
    </xsl:if>



    This should do the trick for you.

    /Jan

     

  • Dan 1288 posts 3921 karma points c-trib
    Jan 06, 2011 @ 18:43
    Dan
    0

    Thanks Jan, that looks like just the ticket!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 06, 2011 @ 21:33
    Jan Skovgaard
    0

    Hi Dan

    You're welcome.

    I forgot to mention this description of the HasAccess() extension in the wiki before: http://our.umbraco.org/wiki/reference/umbracolibrary/hasaccess (posting for future reference for others coming across this post).

    It has a good explanation of the possibilities with it and in combination with the IsProtected extension. Good stuff.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft