Can I set the root folder for the image insert button on a rich text editor profile?
Asked Answered
B

1

6

We have a multi site solution where we would like to establish different RTE profiles for different sites. In these profiles we'd like to be able to set a site specific Images folder in the media library. We'd also like to set a site specific root folder for the Insert Link button.

Is this possible "out of the box"? If so, how?

Being answered 20/8, 2014 at 9:47 Comment(2)
The easiest option for media and links is to restrict read access to items using Permissions and Roles, but doesn't work when you have multi-site editors of course!Coffelt
The best way is to go by making custom profiles and manipulating their behaviour.Linoel
C
6

This is not possible out of the box using a single template. If each site has their own set of templates then you can obviously set the source to the different RTE profiles for each site, but this still not solve the issue of restricting the to specific folders for media library or internal links.

You can override the default controls in /sitecore/shell/Controls/Rich Text Editor/InsertLink/InsertLink.xml and /sitecore/shell/Controls/Rich Text Editor/InsertImage/InsertImage.xml.

Within these you can manipulate the GUID passed to the DataContext.

<CodeBeside Type="Sitecore.Shell.Controls.RichTextEditor.InsertLink.InsertLinkForm,Sitecore.Client"/>
<DataContext ID="InternalLinkDataContext" Root="{GUID}"/>
<DataContext ID="MediaDataContext" Root="{GUID}"/>

The current item is passed as a querystring parameter fo which you can access from the code behind and use your own logic to set the correct root by overriding the InsertLinkForm class. Unfortunately the current item is not passed to the InsertImage.xml control so need to pass through the context item id.

If you take a look at the JS for the InsertImage command located in /sitecore/shell/controls/Rich Text Editor/RichText Command.js then this is the location that the link is generated. You can modify RadEditorCommandList["InsertSitecoreMedia"] function to pass through the id in a similar way to InsertSitecoreLink. The caveat here is I am using a slightly older version of Sitecore 7.2 in which there may have been an issue with Links/Media not remembering the user selection and opening in the same location. You may want to verify the id passed, if so you can use your own parameter.

Place the modified files in /sitecore/shell/Override and Sitecore will use these instead.

This still doesn't help with custom RTE profiles per site and passing through the values but hope this helps.

Coffelt answered 20/8, 2014 at 13:19 Comment(2)
We actually have multiple sites per template set and multiple template sets, so it gets a touch complicated. Editors may have permissions to edit across any site. For component default datasources and datasource locations we rely on queries to localise the data. So if I can get a single profile per template set then I can at least localise the root folder with that override. I'll try and find out how to get hold of the current item from the InsertImage control. Hopefully that's simpler than trying to use a query to localise the RTE profile!Being
@JamesWalford That's fairly normal to re-use the templates and I've worked in this same multi-editor/site scenario, but I don't know how to pass these values through on the template. AFAIK, you can't set the root folder for link/image in RTE, I haven't come across this... I added some detail about the link generation for images.Coffelt

© 2022 - 2024 — McMap. All rights reserved.