1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / hide pages programmatically

hide pages programmatically

2 posts, 0 answered
  1. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    07 Jan 2010
    Link to this post
    I am looking for the best way to hide pages after a user logs in. We have a set of pages that the public views, but then when a user logs in, thos pages will be hidden and a different set of pages will be show.

    How can I programatically hide the pages in the navigation?  I am having trouble using the "Show in Naviagtion" property programatically.

    Thank you for any suggestions.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Jan 2010
    Link to this post
    Hi Laura,

    I am looking for the best way to hide pages after a user logs in. We have a set of pages that the public views, but then when a user logs in, thos pages will be hidden and a different set of pages will be show.

    You can set different permissions for each page or group of pages based on roles. Say you have two pages

    -PageOne - set AllowAnonymous access to deny from page properties tab.
    -PageTwo - set AllowAnonymous access to deny from page properties tab.

    You also have two roles - Role1 and Role2.

    Role1 - PageOne -  View - yes , PageTwo View - deny
    Role2 -  PageTwo View - yes , PageOne View - deny

    When user from role 1 is logged in he/she will not see PageTwo. In this post opened by you I described how you can manipulate the navigation based on roles programmatically.

    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
    {
     
        CmsSiteMapNode hideNode = e.Item.DataItem as CmsSiteMapNode;
        if (hideNode != null && UserManager.IsCurrentUserInRole("restricted"))
        {
            hideNode.Navigable = false;
        }
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered