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

Forums / Developing with Sitefinity / Problem Getting BlogID from the meta data defined..

Problem Getting BlogID from the meta data defined..

2 posts, 0 answered
  1. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    02 Feb 2010
    Link to this post
    Hi All,
    I am currently working with blogs , here There is a list of blogs with their (title, Author name, time and date ) being displayed in a repeater.
     publication date is fetched using telerik:DateTimeLiteral by assigning it the ID Publication_Date ,
    now i tried to get the blog id the same way i assigned the label control the id blogID as defined in meta data but it did not show any ID ...... Is it because it is a GUID type and what can i do to get that ID...

    thanks

    Regards
    Adeel Arif.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    02 Feb 2010
    Link to this post
    Hello Adeel Arif,

    Thank you for using our services.

    The blog id is not meta data, thus it can not be accessed in a way such as you wish. The easiest way to get the item ID would be to either create a custom blog posts control which will expose the item ID to the template. Or just modify the control template for the blog items list to get the blog post id from the repeater on data bound:
    <script type="text/C#" runat="server">
        protected void Page_Load()
        {
            repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
        }
     
        void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Telerik.Cms.Engine.IContent blogItem = (Telerik.Cms.Engine.IContent)e.Item.DataItem;
                Guid blogItemID = blogItem.ID;
                Literal blogItemIDLiteral = e.Item.FindControl("blogItemIDLiteral") as Literal;
                if (blogItemIDLiteral != null)
                {
                    blogItemIDLiteral.Text = blogItemID.ToString();
                }
            }
        }
       </script>



    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
2 posts, 0 answered