Adding Blog Post Titles to a Dropdown List 5.0

Posted by Community Admin on 04-Aug-2018 13:23

Adding Blog Post Titles to a Dropdown List 5.0

All Replies

Posted by Community Admin on 19-Jun-2012 00:00

Hi,

I am working on creating a blog post summary page and would like to query a list of all blog post titles.  I've figured out how to query blog posts using the API but I can't figure out how to actually get the title of the post.  All of the examples I am finding use GetMetaData but it doesn't look like this option is available in Sitefinity 5.02860.  

Here is an example snippet I found on in this post, how do I convert this to work with 5.0?

protected void Page_Load(object sender, EventArgs e)
   
       BlogManager manager = new BlogManager("Blogs");
       IList listOfAllPosts = manager.Content.GetContent();
       foreach (IContent cnt in listOfAllPosts)
       
           string val = (string)cnt.GetMetaData("Title");
           ListItem item = new ListItem(val,val);
           DropDownList1.Items.Add(item);
       
  
   


Thanks for any assistance.

Posted by Community Admin on 19-Jun-2012 00:00

I've figured out the answer.  

Here is the updated code:

                          BlogsManager manager = BlogsManager.GetManager();
            var listOfAllPosts = manager.GetBlogPosts();
            foreach (IContent cnt in listOfAllPosts)
                string val = (string)cnt.Title;
                ListItem item = new ListItem(val, val);
                DropDownList1.Items.Add(item);
            

This thread is closed