Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
30 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to add an entry to a blog. The namespace<br />
StarCommunity.Modules.Blog is described by clicking on its name. Make sure you add the assemblies as a reference,<br />
mentioned in 1.1.1.<br />
using StarCommunity.Modules.Blog;<br />
using StarCommunity.Core.Modules;<br />
Adding a Blog Entry with Publication Dates<br />
To add an Entry with specific publication dates, it is easier to use an Entry constructor that allows it. After crating the<br />
object, we have to commit it in the database using BlogHandler object.<br />
In the example below a GuestAuthor adds a new blog Entry. This blog Entry will be published in 7 days, and since then<br />
will always be published (DateTime.MinValue means that this date is not considered when determining publication state<br />
of the entry).<br />
Blog blog = BlogHandler.GetBlog(12);<br />
IAuthor author = new GuestAuthor("John");<br />
Entry entry = new Entry(blog, author, "Entry title",<br />
"Entry content", DateTime.Now.AddDays(7), DateTime.MinValue);<br />
BlogHandler.AddEntry(entry);<br />
Publication Dates Meanings<br />
When creating an Entry (as in the example above), we need to provide both publication start and publication end date.<br />
If any of these dates will be DateTime.MinValue, it means that this date shall not be considered. This means that if we<br />
provide DateTime.MinValue as publication start date, then there is no publication start date – the entry is in published<br />
state until the publication end date. If the publication end date is DateTime.MinValue, it means that there is no<br />
publication end date – the entry is published since the publication start date. Analogically, if both dates are<br />
DateTime.MinValue, the entry is published since the creation date.<br />
2.9.6 Getting Blog Entries<br />
It is very often needed to retrieve blog entries, e.g. to list them on a web site. <strong>EPiServer</strong> Community provides several<br />
overridden methods that allow entries to be retrieved for specific blog.<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to add an entry to a blog. The namespace<br />
StarCommunity.Modules.Blogis described by clicking on its name. Make sure you add the assemblies as a reference,<br />
mentioned in 1.1.1.<br />
using StarCommunity.Modules.Blog;<br />
© <strong>EPiServer</strong> AB