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.
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>
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:
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
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.
This should do the trick for you.
/Jan
Thanks Jan, that looks like just the ticket!
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
is working on a reply...