I know I have done this before but I can't seem to remember where or how.
I want to create a link to an Item in Sitecore. This code:
Sitecore.Data.Items.Item itm = Sitecore.Context.Database.GetItem(someID); return itm.Paths.Path.ToString();
Produces the following string:
http://localhost/sitecore/content/Home/Item1/Item11/thisItem
I would like to have this string instead:
http://localhost/Item1/Item11/thisItem.aspx
What is the correct way to get the path to the item? In this case I can't use a normal Sitecore link:
Sitecore.Web.UI.WebControls.Link
Go to your site's Extras folder. Right click the LinkItems folder and select Insert > Link Item.
Right-click in the Link field in the record for which you want to create a hyperlink. Point to Hyperlink and select Edit Hyperlink. To remove a hyperlink, right-click the linked text in the field, point to Hyperlink and select Remove Hyperlink.
In the Experience Editor or the Content Editor, navigate to the item where you want to insert an anchor. Open the Rich Text Editor and select the text or image that you want make an anchor. In the Hyperlink Manager dialog, click the Anchor tab and in the Name field, enter a unique name for the anchor. Click OK.
You're needing this one, assuming you're running Sitecore v6 or anything more recent (tested with 8.2-6, should work with 9 too):
Sitecore.Links.LinkManager.GetItemUrl(item);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With