IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
When creating a blog post, you must perform the following:
Check whether the blog post already exists.
Before you create the blog post, you must check whether a blog post with the same ID already exists.
Create the blog post.
If the blog post does not exist, you create a new blog post with the specified ID.
Specify the parent blog of the blog post.
Specify to which blog the blog post belongs.
Set the required properties.
When creating a new blog post, it is recommended to set at least the following properties:
You can also set any other properties (e.g. Author, Summary, etc.) in this step.
Save the blog post.
Save all changes that you have made to the blog post.
Publish the blog post.
Finally, you publish the blog post using the workflow manager.
The example below shows you how to create blog post with predefined ID.
NOTE: The ID argument is assigned to the master version of the blog post. For more information about the different versions of a blog post, see For developers: Content lifecycle.
The following code creates a blog post with the specified ID, Title and Content.
First, you get an instance of the BlogsManager class. You check whether a blog post with the same ID already exists. To create the blog post, you call the CreateBlogPost method of the BlogsManager class. You can create a blog post with either predefined or auto-generated ID depending on which overload of the method you use. The method returns the master version of the blog post. Then, you set the properties of the master version. It is recommended to set at least the following properties: Title, Content, UrlName, LastModified, PublicationDate, DateCreated. To save the changes, you call the SaveChanges method of the manager. Finally, to publish the blog post, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.
First, you check whether a blog post with the same ID already exists. Then, if it does not exist, you create the blog post by calling the CreateBlogPost method of the singular facade of the parent blog. The ID argument is assigned to the ID master version of the item. To set the properties of the blog post, you call the Do method of the facade. Then, you save the changes. Finally, to publish the blog post, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important