1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to retrieve News GUID in detail page?

How to retrieve News GUID in detail page?

2 posts, 0 answered
  1. MJia
    MJia avatar
    44 posts
    Registered:
    09 Jun 2009
    03 Jun 2010
    Link to this post
    Hi,
    I have set up a newslist / detail page and it works fine.
    I need to change the layout of the detail page so I specify a new ascx page for the new layout: /Sitefinity/ControlTemplates/News/styled_ListPageDetails_modified.ascx

    My question is how can I display / or retrieve the GUID of the news that is displaying?

    The url is like this format: [Publication_Date]/[Title].aspx, which is perferred, I don't want the GUID to be part of the url.

    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Jun 2010
    Link to this post
    Hello MJia,

    The code below will return the ID of the item that is being previewed

    Telerik.Cms.Engine.ContentManager Manager = new Telerik.Cms.Engine.ContentManager("News");
    if (Context.Items.Contains(Manager.Provider.ContentItemKey))
    {
        var itemId = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;
     IConent cntObject = Manager.GetContent(itemId);
       if(cntObject !=null)
       {
         string TitleKey = (string)cntObject.GetMetaData("Title");
       }
          

    The url format can be changed from the web.config, providers declaration under cmsEngine node. There is a property urlRewriteFormat

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered