More in this section

Blogs api

4 posts, 0 answered
  1. Michael
    Michael avatar
    31 posts
    Registered:
    07 Sep 2007
    11 Jan 2009
    Link to this post
    I am trying to create some custom controls from the data from my blog posts.  Is there a api reference sheet that show what you can extract from the blogs?

    I found some info in the developer manual, but I what to extract the content of the blog post, not just the title and other MetaData.
    {code}
            // create new instance of BlogManager
            Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager();
            // get all blog posts
            IList listOfPosts = blogManager.Content.GetContent();

            if (listOfPosts.Count > 0)
            {
                foreach (Telerik.Cms.Engine.IContent newsItem in listOfPosts)
                    Response.Write((newsItem.GetMetaData("Title" + "<br />"));
            }
    {/code}
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    11 Jan 2009
    Link to this post
    Hi Michael,

    Blogs module is based on Generic Content module, therefore you will be able to use Generic Content module API to work with the blog posts.

    The blogs API documentation can be found here:
    http://www.sitefinity.com/help/developer-manual/generic-content-based-blogs-api-overview.html

    Since every blog post is actually an object of IContent type, you can use ContentManager class to work with it. More about ContentManager, IContent interface and Generic Content API you can find here:
    http://www.sitefinity.com/help/developer-manual/generic-content-api-overview.html

    To get the content of the blog post, you can use Content property of the IContent interface (remember blog posts are of IContent type). It would look something like this:

    string blogPostContent = blogPost.Content;

    I hope this helps. Let us know if there is anything else we can do for you.

    Greetings,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Michael
    Michael avatar
    31 posts
    Registered:
    07 Sep 2007
    25 Jan 2009
    Link to this post
    I was able to pull out all of the data I need, but is there a way to soft the data by posting date?

    {code}
            // create new instance of BlogManager
            Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager();
            // get all blog posts
            IList listOfPosts = blogManager.Content.GetContent();
            if (listOfPosts.Count > 0)
            {
                foreach (Telerik.Cms.Engine.IContent newsItem in listOfPosts)

                    blogPostTitle += "<h2>" + newsItem.GetMetaData("Title") + "</h2><br />" + newsItem.Content.ToString() + "<br /><br /><hr size=5 noshade color=\"#0F3B05\"><br />";
            }

    {/code}
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    26 Jan 2009
    Link to this post
    Hi Michael,

    You should use some of the GetContent method overloads which provide an option to sort generic content objects by sorting expression. For example:
    GetContent(string sortExp)
    GetContent(int from, int max, string sortExp)
    GetContent(int from, int max, string sortExp, Guid parentID)
    GetContent(string sortExp, params IMetaSearchInfo[] filter)

    Let us know if you need any further assistance.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered