Create link to Sitecore Item

旧巷老猫 提交于 2019-12-03 04:39:36
Mark Cassidy

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);
James Lawruk

If you are still using Sitecore 5.3, you can use this. Be warned this method is deprecated in Sitecore 6.0.

string url = item.Paths.GetFriendlyUrl();

Your Web Control:

<asp:HyperLink ID="HyperLinkItem" runat="server">
    Item
</asp:HyperLink>

Your Code:

var homeItem = Sitecore.Context.Database.GetItem("/sitecore/content/Home");
HyperLinkItem.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem);
Yogesh Sharma

You can render item link as below:

Sitecore.Data.Items.Item itm = Sitecore.Context.Database.GetItem(someID);
return Sitecore.Links.LinkManager.GetItemUrl(itm);

Try this

  <asp:HyperLink ID="hlItem" runat="server">

    </asp:HyperLink>

aspx.cs

   Sitecore.Data.Items.Item itm = Sitecore.Context.Database.GetItem("/sitecore/content/Home");

    hlItem.Navigateurl =sitecore.links.linkmanager.getitemurl(itm);

You can do by this also:

Item.Paths.FullPath

It is same as:

Sitecore.Links.LinkManager.GetItemUrl(item);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!