renderItemTitle is another presentational pipeline introduced in Sitecore 6, allowing to modify the appearance of item blocks, or tiles, in the folder views. Folder view is what you see on the right: a default tab on folder items. You can also add it to any other item by adding it to the Editors list.
Hooking into the renderItemTile allows changing the appearance of individual item tiles. Most often, however, customization scenarios include adding a few bits of information, relevant to all items or to specific item types.
This is how the pipeline looks out of the box (simplified):
<renderItemTile> <processor type="RenderFolderTile" /> <processor type="RenderTemplateTile" /> <processor type="RenderDefaultTile" /></renderItemTile>
The RenderFolderTile and RenderTemplateTile add information relevant to folders (a number of subitems) or templates (a number of usages).
In this example, I’ll be adding information about a number of validation errors of the item.
The processor has to inherit from Sitecore.Pipelines.RenderItemTile.RenderTileBase. This base class is already capable of rendering a default item tile, so I’m just slightly changing its behavior to also output a number of validation errors.
public class RenderItemTile : RenderTileBase { public override void Process(RenderItemTileArgs args) { if (args.View != TileView.Tiles) { return; } base.Process(args); args.AbortPipeline(); } protected override void RenderTileDetails(HtmlTextWriter output, RenderItemTileArgs args) { base.RenderTileDetails(output, args); var errorCount = GetErrorCount(args.Item); if (errorCount == 0) { return; } var message = errorCount > 1 ? "{0} errors".FormatWith(errorCount) : "1 error"; output.Write("<div class="\"scTileItemDetailsLine\"" style="color: red">"); output.Write(message); output.Write("</div>"); } int GetErrorCount(Item item) { var errorCount = 0; var validators = ValidatorManager.BuildValidators(ValidatorsMode.Gutter, item); ValidatorManager.Validate(validators, new ValidatorOptions(false)); foreach(BaseValidator validator in validators) { if (validator.Result >= ValidatorResult.Warning) { errorCount++; } } return errorCount; } }
A few pieces to notice:
As with other pipelines, Sitecore only knows about generic data concepts such as templates, folders and items. We cannot provide the customizations specific to the business domain of each site, but you can. The renderItemTile pipeline can be used to add information that describes each specific item type best: a publication date of the news item, a number of comments of the blog post or a discount percentage for a sales partner. And because it’s a pipeline, you can even display different information to different types of users.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.