I'm using uBlogsy 2.0 beta in Umbraco 4.7.1 for a site I'm developing and I need to get a specific blog post to be restricted to members only when they are signed in, as the post contains confidential info. The rest of the blog is public.
I've tried right click / Public Access and resticting this post to members only. But it is still displayed in the list of posts, and also in the archive list and the RSS feed.
How can I set this so that it's fully available to signed in members but hidden from anyone else?
You need to modify the Macro scripts to do this. In Razor you can make use of the HasAccess and IsProtected properties. On the macros that renders the post and archive information you could add the HasAccess property to determine if the current logged in user has access to the post, below an example how I modified the uBlogsyListPosts.cshtml file, You see that I make use of the HasAccess property now the user will only see the protected item if the user has access and is in the correct role
<divclass="uBlogsy_posts_container uBlogsy_bottom_border"><h2>
Latest posts</h2><ul>@foreach (DynamicNode n in nodes)
{
if (n.HasAccess)
{
<li><ahref="@n.Url"><span>@n.GetProperty("uBlogsyContentTitle").Value</span></a>@* - <span>@n.GetProperty("uBlogsyPostDate").Value.FormatDateTimeOrdinal("d MMMM yyyy")</span>*@</li>
}
}
</ul></div>
For an rss file you only want to make sure the item isn't protected. In the example below I modified the uBlogsyRSS.cshtml file to only show public posts
@foreach (var p in posts)
{
if (!p.IsProtected)
{
<item><title>@p.GetProperty("uBlogsyContentTitle").Value</title><author>@p.GetProperty("uBlogsyPostAuthor").Value</author><comments>@blogUrl@p.Url</comments><description>@p.GetProperty("uBlogsyContentBody").Value.StripHtml().Trim()</description><link>@blogUrl@p.Url</link><guid>@blogUrl@p.Url</guid><pubDate>@p.GetProperty("uBlogsyPostDate").Value.FormatDateTime("ddd, dd MMMM yyyy HH:mm:ss") </pubDate></item>
}
}
For more info about Razor check out this cheat sheet.
Member only access to a blog post
I'm using uBlogsy 2.0 beta in Umbraco 4.7.1 for a site I'm developing and I need to get a specific blog post to be restricted to members only when they are signed in, as the post contains confidential info. The rest of the blog is public.
I've tried right click / Public Access and resticting this post to members only. But it is still displayed in the list of posts, and also in the archive list and the RSS feed.
How can I set this so that it's fully available to signed in members but hidden from anyone else?
Thanks
Allan
Hi Allan,
You need to modify the Macro scripts to do this. In Razor you can make use of the HasAccess and IsProtected properties. On the macros that renders the post and archive information you could add the HasAccess property to determine if the current logged in user has access to the post, below an example how I modified the uBlogsyListPosts.cshtml file, You see that I make use of the HasAccess property now the user will only see the protected item if the user has access and is in the correct role
For an rss file you only want to make sure the item isn't protected. In the example below I modified the uBlogsyRSS.cshtml file to only show public posts
For more info about Razor check out this cheat sheet.
Hope this helps,
Richard
Hi Richard
That looks great - many thanks. I'll give it a try shortly...
Allan
is working on a reply...