Friday, June 13, 2008

Sitecore Item Url

One of the most common items I have to deal with is managing Sitecore items in .NET. I'm often looking for the url of the item so I can link to it on the page, I thought I would share this with the world.

Sitecore.Context.Item.Paths.GetFriendlyUrl();

Or

Item sitecoreItem = Sitecore.Context.Item;
String itemUrl = sitecoreItem.Paths.GetFriendlyUrl();

Very simple to do but not well documented.

4 comments:

  1. Sitecore functionality, not well documented? No surprise there. Thanks for this.

    ReplyDelete
  2. The new version of this is:

    Sitecore.Links.LinkManager.GetItemUrl(item);

    ReplyDelete
  3. Hi there, I am new to Infopath and I really appreciate all this great information. Thanks for it.

    ReplyDelete