Tuesday, January 17, 2012

Sitecore RichText Commands Custom Media Library

My last post discussed a unique setup where we needed to point the Sitecore Media Library (Insert Sitecore Item) to a different root folder based on the website. We have a multi-site implementation. All have their own distinct Media (Images, Video, Audio & Documents). If we didn't there would be nearly 180,000 items in these folders. To get 6.3.0 to work the following changes need to be made. in sitecore\shell\Controls\Rich Text Editor\RichText Commands.js add the following to the RadEditorCommandList["InsertSitecoreMedia"] = function(commandName, editor, tool):
var editedItemId = ''; if ((document.location) && (document.location.search)) { var qStr = top.location.search.substring(1); var keyValList = qStr.split("&"); for (var i=0; i 1) { if (splitPair[0] == "id") { //Value was already escaped, no need to unescape and re-escape editedItemId = splitPair[1]; } } } } } And then I had to add to the query string variables of editor.ShowDialog: + (editedItemId ? "&editedItemId=" + editedItemId : "")
This will allow Sitecore to check for an existing item and go directly to it in the Content Tree. Otherwise it will default to the current sites Media folder. Really simply to implement and makes managing 300,000 items of content much easier.

No comments:

Post a Comment