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

Forums / Developing with Sitefinity / Blog API - Get Current Post?

Blog API - Get Current Post?

4 posts, 1 answered
  1. Jay
    Jay avatar
    51 posts
    Registered:
    16 Jul 2008
    20 May 2010
    Link to this post
    I'm trying to create some custom controls for blog.  On my my individual blog post page, I'd like to retrieve the current post so that I can access some of its data, like the title.

    In the API docs I see lots of info on how to use the BlogManager.Content.GetContent method to return a list of ALL posts.. or to return a post by a specific GUID.  My question is:  How do i retrieve the current post?

    For regular pages I can use Sitemap.CurrentNode to get the page ID... but since the post page is generated dynamically this doesn't work.  I want the ID of post, not the idea of the page that displays it.

    Thanks in advance.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 May 2010
    Link to this post
    Hi Jay,

    You can add the following  code to ListPageDetails.ascx template which shows the details mode of a given post. The code will return the ID of the item that is being displayed and the content item if necessary

    protected void Page_PreRender(object sender, EventArgs e)
      {
          Telerik.Cms.Engine.ContentManager Manager = new Telerik.Cms.Engine.ContentManager("Blogs");
          if (Context.Items.Contains(Manager.Provider.ContentItemKey))
          {
              var itemId = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;
     
              // set the Full Results here
          
      


    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.
    Answered
  3. Jay
    Jay avatar
    51 posts
    Registered:
    16 Jul 2008
    20 May 2010
    Link to this post
    That was exactly what I needed.

    Thank you... again... for the 100th time... for your quick and helpful response.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 May 2010
    Link to this post
    Hi Jay,

    Always glad to help to the community.

    Best wishes,
    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.
Register for webinar
4 posts, 1 answered