Skip to content
adeneys edited this page Nov 2, 2012 · 2 revisions

Configuring Blog Template Settings

WeBlog allows you to use your own templates for entries, categories, and comments on a "blog-by-blog" basis. The primary scenarios for this would be either adding fields on these templates to support your requirements, or altering the standard presentation of these templates for different blogs on your site. For example, you might want to feature different sidebar components on different blogs, running in the same Sitecore instance. The new templates need to be configured on the blog so that WeBlog is able to create items of the correct template(s) as needed, as well as to find items of the correct template(s) in its search index.

Even if you are deploying a single blog without any template modifications, you may want to consider creating your own Entry and Category templates anyway. This allows you to modify Standard Values presentation settings without touching the WeBlog default templates, potentially easing future upgrades.

The steps to utilize custom templates on your blog are as follows:

  1. Create new templates for the desired WeBlog entities. Ensure your template(s) inherit from the appropriate !WeBlog default templates. a. Entry - /sitecore/templates/Modules/WeBlog/BlogEntry a. Category - /sitecore/templates/Modules/WeBlog/BlogCategory a. Comment - /sitecore/templates/Modules/WeBlog/BlogComment
  2. If desired, create Standard Values items for your Entry and Category templates, and edit their presentation settings.
  3. On your root Blog item, edit the Alternate Templates and select your newly created templates.
  4. If you have existing items, they must be updated to utilize the new templates. This can be done item by item, or using a scripting tool such as Revolver or Sitecore PowerShell. a. Techphoria414 article on using PowerShell to do this
  5. Referencing the NewsMover configuration in WeBlog.config for the existing templates, configure item:saved event handlers for your new Entry and/or Comment template(s).
  6. Add your new Entry and/or Comment template(s) to the included templates in the WeBlog search index.
  7. Publish and test!

The two configuration updates can be accomplished by creating a WeBlog.Custom.config in App_Config\Include and "patching" the base WeBlog.config. For example:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
	<sitecore>
		<events>
			<event name="item:saved">
				<handler type="Sitecore.Sharedsource.Tasks.NewsMover, Sitecore.Sharedsource.NewsMover" method="OnItemSaved" patch="myEntry">
					<database>master</database>
					<datefield>__created</datefield>
					<articletemplate>MyTemplates/Blog/Entry</articletemplate>
					<yeartemplate>common/folder</yeartemplate>
					<monthtemplate>common/folder</monthtemplate>
					<!-- Uncomment the following line if you have too many posts per month (more than 100) -->
					<!--<daytemplate>common/folder</daytemplate>-->
				</handler>
				<handler type="Sitecore.Sharedsource.Tasks.NewsMover, Sitecore.Sharedsource.NewsMover" method="OnItemSaved" patch="myComment">
					<database>master</database>
					<datefield>__created</datefield>
					<articletemplate>MyTemplates/Blog/Comment</articletemplate>
					<yeartemplate>common/folder</yeartemplate>
					<monthtemplate>common/folder</monthtemplate>
					<!-- Uncomment the following line if you have too many posts per month (more than 100) -->
					<!--<daytemplate>common/folder</daytemplate>-->
				</handler>
			</event>
		</events>
		<search>
			<configuration>
				<indexes>
					<index id="WeBlog" type="Sitecore.Search.Index, Sitecore.Kernel">
						<locations hint="list:AddCrawler">
							<master type="Sitecore.Modules.WeBlog.Search.Crawlers.DatabaseCrawler,Sitecore.Modules.WeBlog">
								<include hint="list:IncludeTemplate" entryTemplate="$(EntryTemplateID)" commentTemplate="$(CommentTemplateID)">
									<myEntry>{D5608C5D-45E4-43FA-B2E4-DCD9DDF3E5A1}</myEntry>
									<myComment>{C85123CF-DA89-4C37-ACFA-4F8BA5157AC1}</myComment>
								</include>
							</master>
							<web type="Sitecore.Modules.WeBlog.Search.Crawlers.DatabaseCrawler,Sitecore.Modules.WeBlog">
								<include hint="list:IncludeTemplate" entryTemplate="$(EntryTemplateID)" commentTemplate="$(CommentTemplateID)">
									<myEntry>{D5608C5D-45E4-43FA-B2E4-DCD9DDF3E5A1}</myEntry>
									<myComment>{C85123CF-DA89-4C37-ACFA-4F8BA5157AC1}</myComment> 
								</include>
							</web>
						</locations>
					</index>
				</indexes>
			</configuration>
		</search>
	</sitecore>
</configuration>