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

Forums / Developing with Sitefinity / Adding Blog Post Titles to a Dropdown List 5.0

Adding Blog Post Titles to a Dropdown List 5.0

2 posts, 0 answered
  1. Randy Garza
    Randy Garza avatar
    19 posts
    Registered:
    24 Feb 2012
    19 Jun 2012
    Link to this post
    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.
  2. Randy Garza
    Randy Garza avatar
    19 posts
    Registered:
    24 Feb 2012
    19 Jun 2012
    Link to this post
    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);
                }

2 posts, 0 answered