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

Forums / Developing with Sitefinity / Custom Navigation based on a Custom Security

Custom Navigation based on a Custom Security

6 posts, 1 answered
  1. David D
    David D avatar
    13 posts
    Registered:
    17 Oct 2013
    10 Apr 2014
    Link to this post

    We've implemented a custom membership provider and a custom table for permissions etc based on our own user and role base.

     

    Since the out of the box navigation control is based on Roles in Sitefinity we can't use it.  We need to get to a level deeper in our own security implementation.  Do I use a Kendo UI Web menu control and PageManager?  Is there an example someone can point me to or put in here on how to do this?

     

    Thanks,

    David 

  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    14 Apr 2014
    Link to this post
    Hello David,

    One way of implementing the navigation is to bind a hierarchical data control to our SitefinitySiteMapDataSource declarative control, i.e. it would provide the datasource automatically to the control which will use it. You can then subscribe to ItemDataBound event of that control and implement some custom logic for modifying the item when it's bound to the control, since this event will fire for every item that gets bound. You can then filter each item depending on your criteria and choose whether to show it or not.
    Example:
    <asp:Repeater  ID="Repeater1" runat="server" DataSourceID="SiteMapDataSource" >
    </asp:Repeater>
       
    <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource" StartingNodeOffset="0" ShowStartingNode="false" />
    CodeBehind:
    protected void Page_Load(object sender, EventArgs e)
            {
      
              Repeater1.ItemDataBound += new RepeaterItemEventHandler(Repeater1_ItemDataBound);
              Repeater1.DataBind();
                  
            }
      
            void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
      
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
      
                    var data = e.Item.DataItem as PageSiteNode;
                    if (data != null)
                    {
      
                        if (data.ShowInNavigation == false)
                        {
                            e.Item.Visible = false;
                        }
                    }
                }
            }

    Another option is to use a control of your own and bind it to a datasource of pages queried using the Page API.
    Example:
    var source = App.WorkWith().Pages()
                                           .ThatArePublished()
                                           .Where(p => p.ShowInNavigation == true && p.IsBackend == false && p.Id != SiteInitializer.BackendRootNodeId)
                                           .Get()
                                           .ToList();
      
                MyNavControl.DataSource = source;
                MyNavControl.DataTextField = "Title";
                MyNavControl.DataFieldID = "Id";
                MyNavControl.DataFieldParentID = "ParentId";
                MyNavControl.DataBind();

    An example for a custom navigation you can find here.
    I hope you find this useful.

    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. David D
    David D avatar
    13 posts
    Registered:
    17 Oct 2013
    14 Apr 2014
    Link to this post

    This seems good.

    I was having trouble figuring out how to take the Fluent Source you defined in this example and use it in the widget template I've defined along with the asp:SiteMapDataSource.      Is there another way?

    I started looking at implementing a CustomSiteMapProvider in the place of the Sitefinity one so I can define what my site map is based on our custom security... but I immediately received an error.

     

    A required control was not found in the template for "~/SfCtrlPresentation/OpenAccessDataProvider,1d5cbcbced74667ba552ff01008b77a8.ascx". The control must be assignable from type "Telerik.Sitefinity.Web.UI.NavigationControls.SitefinitySiteMapDataSource" and must have ID "dataSource".

     

    I guess Sitefinity doesn't want me to do this?

  4. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    16 Apr 2014
    Link to this post
    Hi David,

    I suppose you are trying to change the navigation default template. In this case the template is searched in a virtual directory, which path is shown in the error message. You can easily fix this by creating an actual folder SfCtrlPresentation in the root of your SitefinityWebApp. The template should be placed in this folder and with this exact name, following the convention <provider>,<id>.ascx or in this case - OpenAccessDataProvider,1d5cbcbced74667ba552ff01008b77a8.ascx . Keep in mind that by switching the default template you should have an exact structure and controls, as in the current scenario a SitefinitySiteMapDataSource control with an ID: dataSource. If you create an entirely new control you will not have this limitation. You can also take a look at this forum post.

    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. David D
    David D avatar
    13 posts
    Registered:
    17 Oct 2013
    16 Apr 2014 in reply to Nikola Zagorchev
    Link to this post

    No I'm simply trying to get a new Widget Template defined and use it in a Page.

     

    That's the error I'm getting.  I didn't make it the default.  I can switch it back to another template for navigation and it's fine.  Just doesn't work with the one I defined.

  6. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    18 Apr 2014
    Link to this post
    Hi David,

    You can also achieve your scenario creating your own SitefinitySiteMapDataSource inheriting from Telerik.Sitefinity.Web.UI.NavigationControls.SitefinitySiteMapDataSource. You can then override the CheckNode method and return bool value whether the node should be present in the navigation or not, depending on your custom logic and scenario.
    You can then replace the SitefinitySiteMapDataSource control in the beginning of one of the default templates with the one you have implemented.

    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
    Answered
6 posts, 1 answered