Showing posts with label Sitecore. Show all posts
Showing posts with label Sitecore. Show all posts

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.

Sunday, September 25, 2011

Sitecore RadEditor and Multisite Media Library

Currently working through an upgrade from 6.0.1 to 6.4.1 yea we are a little behind but we need to catch up and start using some of the features. We have 18 sites in a single Sitecore instance. And about 250,000 items in that tree. During the upgrade process our problem and so far only one we have run into is our custom Media Library. Each site has its own Media folder with a separate Images, Videos, and Audio folders. This makes ownership and maintenance a little easier. How did we do this? There is an override of the InsertImageForm (picture coming soon) that calls a sitecore query: similar to this.
targetPath = "query:ancestor::*[@@templateId='{18F42371-1B85-4EE1-AF6B-20F5AF81BD5D}']/Media";
This uses a technique very simliar to Alex Shyba's example on how to remember the last section when working with Media. Once we deployed 6.3 we ran into an issue where this no longer works. The query appears to be failing and we end up with the default Media Library being displayed. This means that all of our sites no longer have access to their unique media content. My mission this week is to use .NET Reflector and see what's changed in the Sitecore.Kernel.dll and how this override of InsertImageForm needs to be altered. Any suggestions?

Thursday, December 23, 2010

Akamai - Sitecore and CCU Web Services

I just wrapped up work to integrate the Akamai Content Control Utility webservices and automatic purging from Sitecore.

Using the Telerik RadFileExplorer and some crafty C# code I am now able to trigger content purging from the Sitecore Desktop. Just created the service object, collected the parameters and called the webservice.

Pretty cool, I even get an email once the purge has been completed.

//create the purgeResult object
X.Web.Isc.UI.ServiceReference1.PurgeResult r = new X.Web.Isc.UI.ServiceReference1.PurgeResult();
X.Web.Isc.UI.ServiceReference1.PurgeApiClient a;

a = new X.Web.Isc.UI.ServiceReference1.PurgeApiClient();
string[] options = new string[4];
string[] uri = new string[1];

//get the login credential and other data for Akamai from the web.config
options[0] = ConfigurationManager.AppSettings["AkamaiCCUEmail"].ToString();
options[1] = ConfigurationManager.AppSettings["AkamaiCCUAction"].ToString();
options[2] = ConfigurationManager.AppSettings["AkamaiCCUType"].ToString();
options[3] = ConfigurationManager.AppSettings["AkamaiCCUDomain"].ToString();

//build the URL to the file that was uploaded

uri[0] = "http://www.mydomain.com" + e.Path;

//request the content purge
r = a.purgeRequest(ConfigurationManager.AppSettings["AkamaiCCUUserName"].ToString(), ConfigurationManager.AppSettings["AkamaiCCUPassword"].ToString(), "", options, uri);

//log the activity
X.Web.Core.Context.Current.LogMessage("Akamai CCU WebService Message: " + r.resultCode + " " + r.resultMsg + " " + r.sessionID + " " + uri[0].ToString());

}
catch (Exception ex)
{
//something didn't work so let's report the issue
X.Web.Core.Context.Current.LogMessage("Error Akamai CCU WebService Message: ", ex);
}