One of the things that I absolutely love about ExpressionEngine is the ability to create Channels for specific types of content. Statamic has similar capabilities though it takes a different route to get there. In ExpressionEngine you would go into the Control Panel, create a channel, create a channel field group and assign the fields you want to the channel field group. In Statamic you go into _config/fieldsets/ and create a new YAML file with the appropriate fields in it and all of their configuration parameters. This enables an additional Page Type when adding a new page in the Control Panel.
To get started we will navigate to _config/fieldsets/ and create a new file named contact.yaml. To get started let's put the following in the file and save it.
title: Contact Page fields: _template: display: Template type: templates image: type: file display: Upload an Image destination: assets/img show_thumbnail: true where: display: Where It’s At type: location content: display: Page Content required: false default: type: markitup
This code will give us the ability to select our contact template, upload a file (image) to dress up the page, input an address (and plot it on a map!), and display some basic content on the page. It also gives you this when you click on the Create New Page button in the Control Panel!
To extrapolate this and make it something something we can really be proud of we would do something like the following:
title: Contact Page fields: _template: display: Template type: templates image: type: file display: Upload an Image destination: assets/img show_thumbnail: true where: display: Where It’s At type: location content: display: Page Content required: false default: type: markitup results-content: display: Results Page Content required: false default: type: markitup email: type: text display: Email Address phone: type: text display: Phone Number twitter: type: text display: Twitter URL facebook: type: text display: Facebook URL dribbble: type: text display: Dribbble URL linkedin: type: text display: LinkedIn URL
Jack and Fred cover the various Fields that are available on this page. I think it is going to take a full on site build to make me comfortable with the capabilities this brings. For the moment though it makes it easy to do something like the above where I have defined items that are currently on the Blue Fish contact page. Adding the above to the contact.yaml file nets you the following:
The question I have is how do you control the order of the fields? Statamic seems to be ignoring the order in the file. I'll have to ping support and see what they say because in a perfect world I would be able to present the fields in a specific order.
Also, be aware that YAML is very, very, very format sensitive. If you are not used to this then it can throw you for a loop. When I originally put the above code in the contact.yaml file I was not seeing 4 of the fields render on the publish page. Turns out it is because there was a space missing. Adding the space and saving the file made them appear. So be aware that something as simple as a missing space can cause issues.
I think that about does it for this installment. Next I will take a look at how to place the content we just put in the fields . But so far so good with Statamic. I can definitely see the power in this system. It's probably my familiarity with ExpressionEngine that is making this click so quickly for me. The mentality of creating custom post types for various types of content is something that I "get". Statamic certainly makes this easy.