Code First Document Types and How To Create Blocks Within Umbraco
Today's questions were asked by Nicola Ayan.
My two questions are:
- Is there an Umbraco equivalent to Episerver blocks? Does that concept exist at all in Umbraco? My web content authors need to be able to create page sections that they can reuse on other pages and sort amongst each other. I’ve looked at macros and grid editors but these do not suffice.
- Can I build the document types in code and Umbraco to generate these in the database the next time it runs, like Episerver? I don’t like to merge the content and content types in the database for obvious reasons.
In this episode, I answer these questions. First, as long as you are using Umbraco 7.8 then everything is possible and it's all built into the core product.
First code first can be achieved by implement the Umbraco Models Builder. A good overview can be found here: https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
The closet like-for-like to Episerver code-first feature in Umbraco is uSiteBuilder. uSiteBuilder t hasn't been updated for a while but it still works with Umbraco 7.8. As there's a built-in Models builder, I recommend using that though. For reference, uSitebuilder tutorial can be found here:
Another great plug-in I recommend that cab help deployment, is uSync:
If you want to use Episerver block like functionality within your website. You should look at the Grid Layout data type. This useful document type allows content editors to be able to split a page layout into columns and rows. You can set the width of your grid components and it's definitely worth checking out!