Understanding Craft CMS
Craft is a powerful and flexible Web content management system that recently piqued our interest at Black Pixel. While it’s easy to install and features an intuitive templating language for generating Web output, some of its concepts can be hard to grasp. Here we will try to provide a little help for anyone looking at Craft for the first time.
Craft’s core building blocks are entries, sections, and fields.
Entries are articles. Entries always have at least a title (and some metadata necessary to the system). Whether they contain any other data depends on their entry type. Entry types are specific to a section.
Sections are silos of content in Craft. These tend to correspond to the major areas of a site as linked from the header navigation. There are two main kinds of sections: channels and structures. A channel is an arbitrarily ordered list of entries, while the order of a structure is defined by its arrangement in the admin. Dragging entries around in a structure directly affects their output on the Web.
Either type of section can support categorization, though structures lend themselves more to organization via parent entries. An entry can be dragged under any other entry in a structure and will become a child of that parent entry.
It is possible for an entry to belong to multiple categories, but an entry can only ever have one immediate parent entry, or “ancestor.” Of course, that ancestor might have its own ancestor, and so on.
Before an entry can be created in a section, the section must be defined in the Sections area of the admin settings.
The data available to be added to an entry is determined by the fields assigned to its entry type. Entry types are specific to a section. For example, a section for your team’s developers could provide an entry type that supports the Markdown markup language, while another section could feature rich text editing fields instead.
A section can include more than one entry type. Before a field can be assigned to a section’s entry type, it must be defined in the Fields area of the admin Settings.
Entries aren’t the only things that can incorporate fields. You can attach fields to categories, users, and more. Why would you want to do so? Think of fields in an entry as data and fields elsewhere as metadata. An entry has its own data in fields; but, if that entry belongs to a category, your template can draw from the metadata in the category’s fields as well. You might decide, for example, that categories should be color-coded and assign a color value to each category. Adding a color field to your category group’s field layout makes this possible.
Using Entries, Sections, and Fields
Say you want to create a company org chart that you can easily rearrange from within Craft. You might create a structure-type section with two entry types: Department and Team Member. The Department entry type only needs a title. The Team Member entry type can contain much more: first and last name, of course, but also a photo, a short bio, job title, geographic location, and contact info. We can use the first and last name to auto-generate the entry title.
Then it’s a matter of creating entries in each type and dragging the team members into the correct departments. If someone switches roles later, just drag them to the new location. If you like, you can even organize the team members hierarchically to indicate who’s answering to whom.
Categories and tags are completely optional in Craft but quite useful.
Categories are admin-defined organization tools for entries. An entry can belong to multiple categories.
Categories are arranged in category groups, and every category must belong to such a group. This seems arbitrary at first but is actually quite useful. By tying a category group to a section, we can make sure the category options available to the user are always relevant to the content.
Category groups are defined in the Categories section of the admin Settings, though individual Categories are added via the Categories link in the admin navbar.
Tags work much like categories except they are not defined by the admin. Users can create new tags willy-nilly, though Craft’s autocomplete feature helps users reuse existing tags (and helps prevent near-match duplicates).
Like categories, tags are grouped into tag groups. These have the benefit of siloing the autocomplete feature so that the suggestions are relevant to the intent.
Tag groups are defined in the Tags section of the admin Settings. Since tags are user-created, there is no mechanism for adding individual tags via the admin.
Assets are user-submitted files uploaded through the Craft interface for display and download in entries. Assets need not be images; any supported filetype will work. In addition to the natively supported image formats, Microsoft Office documents, PDFs, and .zip archives, other types may be added as needed. You can add support for Keynote files, for example.
Assets can be stored in a remote location such as in Amazon S3. This is really the way to go, as mirroring Craft’s default media folder in version control can be a hassle.
Users are accounts that are granted access to use the Craft install. A user may belong to a user group, which defines its permissions, or it may belong to no group at all.
It is possible to limit a user group’s access to admin features; its ability to create, edit, or delete entries in any particular section; and its control over assets or categories.
Individual users can be granted permissions that do not conform to those of any user group, if special cases arise.
We’ve been very impressed by Craft. If you’re shopping for a content management system, it’s worth a serious look. Understanding these core concepts should give you a nice head start on tapping into its power.
For more insights on Web and mobile development and design, follow Black Pixel on Twitter.