Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
Can anyone please confirm that when looping through pages
Umbraco.IsProtected(curPage.Url) doesn't work?
but
Umbraco.IsProtected(curPage.Id, curPage.Url) does (but has been marked as obsolete?).
If so I'll raise a bug.
Steve
Hi Steve,
I think you need to use this now in latest Umbraco versions:
Umbraco.MemberHasAccess(curPage.Path)
I don't believe this works either!
For a non-logged in user I can see all pages when I loop through.
@{ var pages = Model.Content.Children(); foreach (var page in pages) { if (!Umbraco.MemberHasAccess(page.Url)) { <h1>@page.Url IS PROTECTED</h1> } else { <h1>@page.Url</h1> } } }
But if you change this to (page.Id, page.Url) it works.
I've raised an issue:
http://issues.umbraco.org/issue/U4-10729
Steve, you have to pass the Path parameter of the IPublishedContent to Umbraco.MemberHasAccess() and not the Url.
Path
IPublishedContent
Umbraco.MemberHasAccess()
So you would use:
foreach (var page in pages) { if (!Umbraco.MemberHasAccess(page.Path)) { <h1>@page.Url IS PROTECTED</h1> } else { <h1>@page.Url</h1> } }
I've used this on a site recently and it did work.
DOH!
I got totally blindsided by the URL - of course!
Thanks for the heads up.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco.IsProtected(curPage.Url) doesn't work?
Hi,
Can anyone please confirm that when looping through pages
Umbraco.IsProtected(curPage.Url) doesn't work?
but
Umbraco.IsProtected(curPage.Id, curPage.Url) does (but has been marked as obsolete?).
If so I'll raise a bug.
Steve
Hi Steve,
I think you need to use this now in latest Umbraco versions:
Hi,
I don't believe this works either!
For a non-logged in user I can see all pages when I loop through.
But if you change this to (page.Id, page.Url) it works.
I've raised an issue:
http://issues.umbraco.org/issue/U4-10729
Steve, you have to pass the
Path
parameter of theIPublishedContent
toUmbraco.MemberHasAccess()
and not the Url.So you would use:
I've used this on a site recently and it did work.
DOH!
I got totally blindsided by the URL - of course!
Thanks for the heads up.
Steve
is working on a reply...