Tips on Beginning with Umbraco
October 27, 2010I recently wrote an email to a colleague talking about some points in Umbraco, so I wanted to include some of that here.
There are five main pieces to understand about Umbraco:
- Document Types (held in the database)
- Macros (information is held in the database, but they live in usercontrols)
- Fields (held in the database)
- Templates (found in the masterpages directory)
- Pages (held in the database)
A page is what you would expect – a page that can be created in the CMS (in the Content section, right-click and Create). When you create a page, it has to be a certain document type. A document type can have one or more templates that can be used with it (the user has a choice) and different fields that can be filled out to be used on the front-end (text, images, etc).
In a template, you can choose which fields are displayed in the html (see areas like <umbraco:Item Field="text" stripParagraph="true" runat="server"></umbraco:Item>
and [#text]
).
Macros are really just custom user controls that can come in a variety of forms, for example a custom .Net control and can be added to a template like this:
<umbraco:Macro Alias="MyWidget" runat="server" PassedValue="[#value]" SomethingElseToPass="true"></umbraco:Macro>
These function as normal custom user controls (code-behind, etc). To get Umbraco to pass values (like “value”), you need to add that information about the macro under the Development section.
The database structure is not very clear, and I generally try to avoid it so I don’t mess things up. Another note is that Umbraco cannot be run in a virtual directory, so to do development, you need to set it as your root website.
So, in short, a Page has a Document Type, which gives a user a set of Templates to choose from and Fields to fill out, and the Template determines how those Fields are displayed and if/what Macros are used.