More in this section

Forums / Developing with Sitefinity / How to code to update a blog post

How to code to update a blog post

4 posts, 0 answered
  1. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    12 Nov 2009
    Link to this post

    Does anyone have an example of how to update a blog post with a User Control?  Below is the code that I found to add a new blog post, but I am not able to find anything to update the title and/or the content.  I've also found code to update the Blog Name itself, just nothing for the posts (content).  I've been trying a variety of things with no success.

    Thanks in advance,
    -R

    // create new instance of BlogManager  
            Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager();  
            // get all blogs  
            IList listOfAllBlogs = blogManager.GetBlogs();  
            if (listOfAllBlogs.Count > 0)  
            {  
                // get the first blog item  
                Telerik.Blogs.IBlog firstBlog = blogManager.GetBlog(((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID);  
                // create a blog post by calling the CreateContent method of the  
                // ContentManager class through the BlogManager class  
                Telerik.Cms.Engine.IContent postContent = blogManager.Content.CreateContent("text/html");  
     
                // set the parent of the post item to be firstBlog  
                postContent.ParentID = firstBlog.ID;  
                // save the Content property value and the Title meta key  
                postContent.Content = "My first Post Item includes ...";  
                postContent.SetMetaData("Title", "My Post Item 1");  
                //save the Content item through the BlogManager  
                blogManager.Content.SaveContent(postContent);  
     
                Response.Write(firstBlog.Name + " has following content : " + postContent.Content + "<br />");  
            } 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    12 Nov 2009
    Link to this post
    Hi Randy Bauer,

    Below is a code that illustrates required functionality

    BlogManager blogManager = new BlogManager("Blogs");
    IContent blogPost = blogManager.Content.GetContent(cntID);
    blogPost.SetMetaData("Title", "NewTitle");
    blogManager.Content.SaveContent(blogPost);


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    12 Nov 2009
    Link to this post
    Thank You, Thank You...

    I've spent hours trying to get that to work.  I was close, but just couldn't get it.  Is there documentation on how to do this?

    Thanks Again,

    Randy
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    12 Nov 2009
    Link to this post
    Hi Randy Bauer,

    Take a look at our developers manual -Modules API Overview

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered