Now we’re going to create the Project Category custom attribute. Before we continue, a note about the name: this isn’t the best naming convention that we could have chosen. It’s generally not a great idea to have two categorization concepts that fight one another. What is a type? What is a category? Why choose one or the other?
The simple answer for this tutorial is that our theme has a semi-arbitrary distinction between types (those little badges that we’ve already included in our custom page title template, and categories, which the Projects page shows and allows filtration by. So we’re going to follow that model, even though if we were working with a client we might encourage them to make a less confusing choice. But that’s where we are. Let’s create our custom attribute that will eventually power this section of the Projects page.
Our attribute -- again, named Project Category -- will be an Option List attribute (just like the Project Type) except it will have the following options in it:
- Architecture
- Interior
- Exterior
- Drafting Landing
Much like the Project Type attribute, we’ll create this in our attributes.xml
file.
Copy the Project Type Attribute
Open attributes.xml
and highlight the entire <attributekey>
belonging to the Project Type attribute:
Why are we starting with this? Because the Project Type attribute is very similar to our Project Category attribute -- it just has different values.
Paste the attribute key into the XML file and update the handle, name and <option>
nodes:}
Finally, let’s make sure the project_category
attribute is in the same Dreamrs attribute set that we added Project Type to:
Upgrade the Package
Now, let’s upgrade the package to install our attribute. Increment the $pkgVersion
property in the controller.php
file to 0.6.5
. Then, upgrade the package by running
concrete/bin/concrete5 c5:package:update dreamrs
from the command line.
When we verify that the attribute set ! We can now see our new attribute set in the Page Attributes Dashboard Page, with our custom attribute available:
Now we’ll be able to rely on this attribute existing when we create our Project Grid block type.