It's no secret that Sitecore is a true developer's platform - powerful, flexible, and entirely too hard to get spun up into a proper solution. Sitecore doesn't even have the concept of a web page right out of the box (it takes a developer to create the proper templates, presentation pieces, backend code, and more to create a simple, addressable web page).
Developers, the Sitecore community, and even Sitecore themselves have tried to address this difficulty with various tools over the years - Glass Mapper, Synthesis, SXA, Unicorn, TDS, Sitecore Rocks, PowerShell Extensions - the list of great dev tools goes on and on.
Over the years I've written a few tools, scripts, and shortcuts that has aided my own development, and throughout 2021 I'll be releasing some of those back to the community.
Say hello to Blaze for Sitecore.
What is Blaze?
In short, Blaze is a series of loosely related tools, libraries, packages, and modules that I've written to address some common pain points when I'm working with Sitecore.
Some are big modules that integrate into many areas of Sitecore, while others are simple one-file tools that address a single need.
First Up: Item Extensions
My first release is a subset of my ItemExtensions
helper methods. These are a collection of extention methods for the Sitecore.Data.Items.Item
class that help load and transform data from a Sitecore item into native C# types.
The Sitecore API provides fast and efficient access to content items, but it requires a little work to ensure the data is type-checked and massaged into useful data types before being used in a model or on a view. ItemExtensions
fills this gap.
Here's a quick example of how it is used:
Item sourceItem = RenderingContext.Current.Rendering.Item;
string title = sourceItem.LoadText("Title"); // Single-Line Text
string body = sourceItem.LoadText("Body Copy"); // Rich Text
DateTime offerExpires = sourceItem.LoadDateTime("Offer Expires"); // DateTime
LinkField callToAction = sourceItem.LoadGeneralLink("Call To Action") // Sitecore LinkField
Sitecore content is converted to native .NET / C# types as much as possible, or returned as Sitecore API types (i.e. LinkField
) whenever it makes sense and preserves the intended functionality of the original template field type.
This is a fairly simple tool, so feel free to extend it to fit your project's needs.
Get Started
GitHub repo: Blaze for Sitecore: Item Extensions