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

Forums / Developing with Sitefinity / Set radEditor tools per role?

Set radEditor tools per role?

13 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    21 Oct 2009
    Link to this post
    I was reading this forum post:


    It describes how to set the radEditor tools for one page but does that have to be done to every page or is there a central location where I can set it? 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Oct 2009
    Link to this post
    Hello Connections Academy Developer,

    The article describes how to add css classes to RadEditor for forum posts and ForumControl where RadEdiotor is used. Since we use embedded templates for all other GeneriContent based modules you need to map the template and modify it.

    Another option is working with Editor ToolsFile.xml which is used to configure the RadEditor control. More information at Using the ToolsFile.xml, External CSS Files.

    Best wishes,
    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.
  3. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    21 Oct 2009
    Link to this post
    Thank you for your quick response. I am trying to set the radEditor tools file specifically based on user role. I have this working but for some reason when I set the tools file in page load, the radEditor content area background turns blue. If I set the tools file in the radEditor tag, the content area background is white which is what we want. Why would setting the tools file in page load produce this behavior and how do I fix it?

    <script type="text/C#" runat="server"> 
     
        protected void Page_Load(object sender, EventArgs e)  
        {
    if (UserManager.IsCurrentUserInRole("Administrators"))
    textEditor.ToolsFile = "~/Sitefinity/Admin/ControlTemplates/EditorToolsFileAdmin.xml";
    else
    textEditor.ToolsFile = "~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml";
        } 
    </script>
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Oct 2009
    Link to this post
    Hello Connections Academy Developer,

    The background of the ContentArea cannot be changed on PageLoad, because when you try to set the ToolsFile the editor is reinitialized and it loads the global css from where the body background is loaded.

    The solution is subscribing for OnPreRender event of RadEditor control and set the ToolsFile.

    Sample code:

    public void Page_Load(object sender, EventArgs e)
        {
             Editor.PreRender += new EventHandler(Editor_PreRender);
             
        }
     
        void Editor_PreRender(object sender, EventArgs e)
        {
            if (!Telerik.Security.UserManager.IsCurrentUserInRole("administrators"))
            {
                Editor.ToolsFile = "~/Files/EditorToolsFile.xml";
                // WE ARE ADDING EMPTY CSS TO MAKE THE HACK.
                Editor.CssFiles.Add("~/empty.css");
            }
        }

    You also received a reply to your support ticket with some more description.

    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.
  5. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    15 Aug 2011
    Link to this post
    What file/page would I need to add this code so that it worked for all of the editors whether it was Generic Content, News, Newsletters, Lists...etc

    I want to have all the tools available to admins but lock down to a basic set of tools for content editors accross the board.

    Any help is appreciated
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Aug 2011
    Link to this post
    Hello Bleutiger,

    You have to map the template for each view you want to change. Please take a look at this KB.

    All the best,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    19 Oct 2011
    Link to this post
    I know this is an old post but I am just now getting back to this.

    When you say it has to be added to each template can you explain.  I know how to map to external templates but can you give me a real world example?

    For example if I wanted to change the editor tools for someone editing Generic Content items Either on a page or in the Generic Content Module?

    News Items?


  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Oct 2011
    Link to this post
    Hello,

    Each view has a template. There is an Admin.master page that is used by all views. You can use the master page and get all controls from a view. The problem with this way is that the hierarchy of templates is different and you need to write a function that recursively gets require controls from this template, then set the properties you want.

    All the best,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  9. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    24 Oct 2011
    Link to this post
    Can you be more specific as to "each View has a template". 

    Which template goes to what?
    Do I just add the code to the top of the page in a script block?
  10. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    24 Oct 2011
    Link to this post
    I have tried the code above and it does not change the radEditorTools in the GenericContent module.

    I added the code to ~/Sitefinity/Admin/ControlTemplates/Generic_Content/ContentEditView.ascx

    Is that correct?
  11. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    24 Oct 2011
    Link to this post
    OK...I have this working finally...sort of.

    I figured out that you must add the code to both the ContentEditView and the ContentNewView so that it will work regardless if you are creating a new item or editing an existing item.

    I think that was an important point that should have been brought out.

    However,  I am having the similar issue to the person above.  My editor background is blue not white.

    I copied your code exactly as it appears above.

    I don't have an empty.css file though.  Do I need one to make the editor background white?

    If so what class do I use to make the editor background white?
  12. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    06 Dec 2016
    27 Oct 2011
    Link to this post
    Hello Bleutiger,

    Yes you need an empty .css file and you specify the path to it like mentioned
    // WE ARE ADDING EMPTY CSS TO MAKE THE HACK.
                Editor.CssFiles.Add("~/empty.css");
    //add relative path to the location of the empty css
    There is no class applied to the the area where you enter content in all instances of the editor. It is actually an empty html document where content can be added. Don`t add any specific styles in the empty.css.

    All the best,
    Stanislav Velikov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  13. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    27 Oct 2011
    Link to this post
    Thanks,

    I actually already tried this and got it to work.

    I appreciate the time though.
Register for webinar
13 posts, 0 answered