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

Forums / General Discussions / Show in navigation

Show in navigation

2 posts, 0 answered
  1. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    16 Dec 2009
    Link to this post
    Hi I'd like to hide pages on a public site but still have them showing in all controls on the admin site.  Is there a way to set Show In Navigation to No in the admin and still see the pages in the admin?

    Thanks,
    Devin
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Dec 2009
    Link to this post
    Hello Devin,

    You can achieve this if you bind all navigation controls that you use to list of ICms pages using CmsManager.GetPages() method. Then read the mode (backend - frontend) using the QueryString, loop through the items and hide those pages for which Navigable property is set to false.

    Sample code:

    manager = new CmsManager();
    IList AllPages = manager.GetPages();
    var newColl = AllPages.Cast<ICmsPage>().ToList();
    RadTreeView1.DataTextField = "MenuName";
    RadTreeView1.DataFieldID = "ID";
    RadTreeView1.DataFieldParentID = "ParentID";
    RadTreeView1.DataNavigateUrlField = "StaticUrl";
    RadTreeView1.DataSource = newColl;
    RadTreeView1.DataBind();

    to hide the node you can use the following code

    HttpContext context = HttpContext.Current;
      if (CmsUrlContext.Current != null && context.Items["cmspagemode"] == null)
      {
          manager = new CmsManager();
          IList AllPages = manager.GetPages();
          foreach (ICmsPage page in AllPages)
          {
              if (!page.Navigable)
              {
                  // hide the node
                  // RadMenuItem
                  // RadPanelBarItem
                  // RadTreeNode
              }
          }
      }

    Note that looping through all pages will result in the website perfromance.


    All the best,
    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