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

Forums / Suggestions / Master Page / Template Permissions

Master Page / Template Permissions

2 posts, 0 answered
  1. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Dec 2009
    Link to this post
    It would be useful for the administrator to be able to specify permissions for each of the Master Pages / Templates so that different Roles / Groups can be given rights to use only specific Master Pages / Templates.

    Regards,
    Jacques
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Dec 2009
    Link to this post
    Hello J.Hov,

    Thank you for your suggestion, we will consider it for Sitefinity 4.0. There could be some hack in the current 3.x version as well.

    1. Create a class that inherits from TemplatesList and override OnPreRender. Then get a template from templates collection. Below is the complete implementation.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI;
    using System.Collections;
    using Telerik.Cms;
    using System.Web.UI.WebControls;
    using Telerik.Security;
     
    /// <summary>
    /// Summary description for TemplatesListCustom
    /// </summary>
    ///
     
    namespace Telerik.Samples
    {
        public class TemplatesListCustom : TemplatesList
        {
            public TemplatesListCustom()
            {
                //
                // TODO: Add constructor logic here
                //
            }
     
            protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                IList templates = (IList)this.DataSource;
                foreach (IPageTemplate temp in templates)
                {
                    LinkButton btn = ((LinkButton)this.FindControl(temp.ID.ToString()));
                    if (btn != null && btn.Text.Equals("Blank") && UserManager.IsCurrentUserInRole("somerole"))
                    {
                        btn.Visible = false;
                    }
                }
            }
        }
    }

    Open \Sitefinity\Admin\ControlTemplates\PageTemplates\TemplatesListEditor.ascx and replace the default TemplatesList control with the custom one.

    2. You can disable template selection from the PageEdit mode by crating a custom class that inherits from Edit Page class

    sample

    public class HackEditPage : EditPage
    {
        public HackEditPage()
        {
        }
      
        // override CreateChildControls method.
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
      
            //Find the toolbar control
            ToolBar toolbar = this.Form.FindControl("toolbar") as ToolBar;
            // find the container where themes DropDownList control is located
            // here you can use recursion as well.
            Control cntr = toolbar.Controls[0].Controls[0];
               ....
                    .....
            if (cntr != null && toolbar != null)
            {
                // find the DropDownList control
                 DropDownList ddList = cntr.FindControl("themes") as DropDownList;
                   // loop through the list items
                    foreach (ListItem item in ddList.Items)
                    {    
                        // do something here or manage ddList control
                    }
             }
         }
      
    }


    Sincerely yours,
    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