I have created a template that has two text fields, on is called non-members text and the other is called members text, Is it possible to have only the non-members text showing unless the user is logged on? I would Ideally like a message that says to view the rest of the article please log on. The content must not be shown at all and cannot be just in a hidden div because it would be visible in the source code. The template is as follows, I'm hoping there is some sort of member control that can be put round the memberstext div that will not show it unless the user is logged on and will instead show a link to the login page or something similar:
Thanks for the reply Petr, when I tried to create this XLST file I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object. at umbraco.BusinessLogic.StateHelper.GetCookieValue(HttpContext context, String key) at umbraco.BusinessLogic.StateHelper.HasCookieValue(String key) at umbraco.cms.businesslogic.member.Member.CurrentMemberId() at umbraco.cms.businesslogic.member.Member.IsLoggedOn() at umbraco.library.IsLoggedOn()
Restricting some page content unless logged on
Hi,
I have created a template that has two text fields, on is called non-members text and the other is called members text, Is it possible to have only the non-members text showing unless the user is logged on? I would Ideally like a message that says to view the rest of the article please log on. The content must not be shown at all and cannot be just in a hidden div because it would be visible in the source code. The template is as follows, I'm hoping there is some sort of member control that can be put round the memberstext div that will not show it unless the user is logged on and will instead show a link to the login page or something similar:
Create simple macro and use umbracolibrary:isloggedon
something like this
<xsl:choose>
<xsl:when test="umbraco.library:IsLoggedOn()">
<xsl:value-of select="data [@alias = 'memberstext']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="data [@alias = 'nonmembersText']" />
</xsl:otherwise>
</xsl:choose>
or use umbraco.library:IsLoggedOn() directly in template with <% %>
Thanks for the reply Petr, when I tried to create this XLST file I get the following error:
Ok I have solved it myself, I needed to add = 1 to the IsloggedOn statement as follows:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.