2

I have a Sitecore custom app that is basically a search screen. I would like for the user to be able to click on a link in the search results and open that content item in the content editor. Does anyone know how to do this?

Corey Burnett
  • 7,312
  • 10
  • 56
  • 93

3 Answers3

3

What you need to do is to use the fo parameter with the id of the item as the value of the paremeter at the end of the content editor path, e.g.:

http://localhost/sitecore/shell/Applications/Content%20Editor.aspx?fo={4142d44b-2237-4795-b219-85e70420fced}

Edit after the comment: If you want to start a new application with content editor within Sitecore, you can use method:

Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString();
parameters.Add("id", item.ID.ToString());
parameters.Add("fo", item.ID.ToString());
Sitecore.Shell.Framework.Windows.RunApplication("Content Editor", parameters.ToString());

This is described in a post Launch Content Editor from code

And here is another solution by Mark Ursino which does same thing using javascript onclick events: http://firebreaksice.com/link-directly-to-a-sitecore-item-in-a-custom-editor/

Community
  • 1
  • 1
Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
  • That works. However it opens up the Content Editor in my Custom App window within Sitecore. So when I open my Custom App it comes up in it's own window. When I click on the links they open up in that same window. If at all possible I would like to open the Content Editor application in Sitecore and have it be on the right item. – Corey Burnett May 13 '13 at 19:07
  • No. I am getting the following error: Parameter named "Command" cannot be null. When I look at the stack trace the exception is being thrown here: Sitecore.Web.UI.Sheer.SheerResponse.Broadcast(ClientCommand command, String frameName) +407 – Corey Burnett May 13 '13 at 19:40
  • I am running the code that you supplied in the code behind for my custom app. – Corey Burnett May 13 '13 at 19:41
  • It seems like that sample code that you referenced in another post is set up to work from a Command. I am trying to get this to run from some code behind on a Custom App. But maybe I can figure out how to make it in to a Command. – Corey Burnett May 13 '13 at 20:00
  • I have no idea why it doesn't work for you, but I've added another way of achieving what you need to the answer. – Marek Musielak May 13 '13 at 20:01
  • Well, I think it doesn't work because I am not running that code from a Command. And yes, I also saw that link to the JS solution. However that JS solution is expecting that I am trying to link to an item from within a custom editor in Sitecore. That is why scForm works. On my screen that won't work. I am not creating a custom editor. I just have a simple Custom Sitecore Application that runs an ASPX page in its own window. – Corey Burnett May 13 '13 at 20:11
  • Your original answer ended up working. I just had to set the target of the link to "_parent". Once I did that it basically replaced the Custom App with the Content Editor. Thanks! – Corey Burnett May 14 '13 at 15:57
2

John West has some good info in the here: http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/08/Load-or-Reload-an-Item-in-the-Sitecore-ASPNET-CMS.aspx

Opening an new content editor window, can be done by using an url in the following format: /sitecore/shell/sitecore/content/Applications/Content Editor.aspx?id={0}&fo={0}&la={1}&ver={2}

  • That doesn't work either. It does open the Content Editor with the item selected. But it opens it in the same window as the Custom Application. I think that will be confusing to the user where they see a window called "My Custom App" that has the Content Editor open inside of it. Hopefully I am trying to find a solution that opens a new Sitecore window. – Corey Burnett May 14 '13 at 15:48
  • I got it!. I used the link that you provided and I just set the target of the link to "_parent". That way it basically replaces the custom application with the Content Editor. So in effect it closes the custom app and opens the Content Editor in the same window. Perfect! Thanks. – Corey Burnett May 14 '13 at 15:56
1

I created a simple extension method that is currently working in Sitecore 6.5. I haven't tested it in other versions of Sitecore.

public static string ContentEditorUrl(this Item item)
{
    return string.Format("{0}/sitecore/shell/Applications/Content%20Editor.aspx?fo={1}", 
        HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), item.ID);
}
Jon-YYC
  • 187
  • 9