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.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important