More in this section
Forums / Developing with Sitefinity / How to show only author posts in blogpost widget

How to show only author posts in blogpost widget

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. janux
    janux avatar
    6 posts
    Registered:
    21 Oct 2015
    03 Nov 2015
    Link to this post

    Hi,

    I need to show only currently logged user posts in blogpost widget, how can i filter them?

    I got:

    public bool UserIdComp(Telerik.Sitefinity.Blogs.Model.BlogPost post)
        {
                var identity = ClaimsManager.GetCurrentIdentity();
                Guid currentUserGuid = identity.UserId;
                Guid postOwnerId = new Guid(Telerik.Sitefinity.Model.DataExtensions.GetValue(post, "Owner").ToString());
                
                Telerik.Sitefinity.Security.UserManager userManager = Telerik.Sitefinity.Security.UserManager.GetManager();
                if(currentUserGuid.Equals(postOwnerId))
                return true;
                else
                return false;
        }

    It works, but i cant use "if" in RadListView ItemTemplate to check if that post belong to currently logged user cause i want to show only such posts.

    I wanna do sth like this:

    <telerik:RadListView ID="Repeater">

    <LayoutTemplate>

    some data

    </LayoutTemplate>

    <ItemTemplate>

    if(UserIdComp((Telerik.Sitefinity.Blogs.Model.BlogPost)Container.DataItem))

    show post

    </ItemTemplate>

    </telerik:RadListView>

    Thanks in advance

  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    05 Nov 2015
    Link to this post
    Setting permissions on blog posts should do the trick. I believe you can set view permissions to owner. 
  3. janux
    janux avatar
    6 posts
    Registered:
    21 Oct 2015
    06 Nov 2015
    Link to this post
    But i need to show owner posts only on this page, on other i wanna show all blogposts. If i set permissions on blogposts to owner it will be applied on all pages i think.
3 posts, 0 answered