Link Directly to a Sitecore Item in a Custom Editor
Sitecore’s flexibility as a platform allows for some interesting customizations, including adding to the Sitecore application itself. A nice extension is to create a custom editor to be used in the CMS on content items. Creating a custom editor is a fairly straightforward task, but making it behave like the built-in Sitecore editors is a bit trickier. This post will cover a quick tip to allow you to link to other Sitecore items within your custom editor.
In the past I had written a custom editor for Sitecore to query for a collection of specific items and make a table with various properties of them. In this editor I wanted to create a link on each to go to that item in the tree, similar to clicking the template of an item and going directly to that template. I was never able to get this to work so the hack was to link directly to the content editor page in the shell and pass it various query string parameters. This worked but would open up the new item in a new application instance.
Fortunately, John West of Sitecore USA recently provided some working JavaScript to get this working the correct way. The resulting JavaScript from the SDN forum question is pretty simple. First include these JS files:
<script src="/sitecore/shell/controls/InternetExplorer.js" type="text/javascript"></script> <script src="/sitecore/shell/controls/Sitecore.js" type="text/javascript"></script>
Then put the following code on a click event:
scForm.getParentForm().postRequest('','','','item:load(id={GUID OF ITEM HERE})');
To see it in use, here’s a hard-coded inline example. (Don’t forget, the return false in a JavaScript click event is bad.)
<a onclick="scForm.getParentForm().postRequest('','','','item:load(id={GUID OF ITEM HERE})'); return false;" href="#">Go to item</a>
The above approach uses the built-in Sitecore JavaScript objects and functions. There’s also the older approach that I’ve used before, but its a bit of a hack since it links directly to the content editor of the shell with some specific parameters:
link.NavigateUrl = string.Format("/sitecore/shell/sitecore/content/Applications/Content Editor.aspx?id={0}&la={1}&fo={0}", itemId, itemLanguage);
1 Comment + Add Comment
Got anything to say? Go ahead and leave a comment!
Popular Posts
- Using the DataSource Field with Sitecore Sublayouts
- Tame Your Sitecore Treelists
- Write to a Custom Sitecore Log with log4net
- Sitecore Upgrade Strategy
- Rendering Fully Qualified Sitecore URLs
- Sitecore Admin Pages Explained
- Managing CSS in the Sitecore Media Library
- Use Any() Instead of Count() To See if an IEnumerable Has Any Objects
- Sitecore Front-End Development Best Practices
- Scaling Sitecore Presentation Component Data Sources
Recent Comments
- Performance tuning your Sitecore installation | Agile and ALM: Software development today on A Going Live Checklist for Sitecore Websites
- Imran Saleem on Sitecore Avanced Database Crawler Occasionally Provides Null Results
- Ty Cahill on Sitecore Front-End Development Best Practices
- Sitecore Managed Sites as Virtual Folders | Fire Breaks Ice on Sitecore Item and Field Names
- Krimos on Using the DataSource Field with Sitecore Sublayouts
Sitecore Links
- .Sitecore
- Aboo Bolaky
- Alex Shyba
- Anders Dreyer
- aweber1.0
- Brian Pedersen
- Christopher Wojciech
- Coffee => Coder => Code
- Dev Sitecored²
- Everything Web
- Image0.com blog
- John West
- Learn Sitecore
- Let's do Sitecore
- Mark van Aalst
- Matthew Kenny
- Molten Core
- Project Lifecycle
- Sean Kearney
- Sebastian Patten
- Sitecore Australia
- Sitecore Blog
- Sitecore Climber
- Sitecore Development
- Sitecore Gadgets
- Techphoria414
- The Client View
- The Sitecore Experience
- Web Content Management and Delivery
Archives
- April 2013 (1)
- February 2013 (1)
- January 2013 (1)
- December 2012 (1)
- June 2012 (2)
- May 2012 (2)
- March 2012 (1)
- February 2012 (1)
- January 2012 (5)
- December 2011 (4)
- November 2011 (1)
- July 2011 (1)
- June 2011 (1)
- May 2011 (2)
- March 2011 (6)
- February 2011 (2)
- January 2011 (10)

Posted under:
Hello, I’m hoping I can still get a response. I tried using this a few weeks ago, but wasn’t able to get it quite working since I couldn’t find documentation on the format. Today, I realized that the internetexplorer.js file has been eliminating text selection and context menus on my site when opened in IE.
My question(s) is: what is the purpose of internetexplorer.js and why would it do this? I’m not savvy enough to interpret the code.
Thanks.