Add Content Component Item Attributes

Content Components allow you to add attributes flexibly. You can make attributes available to an individual content component, to content components that use a specific template or to all content components.

Adding Attributes to Content Component Templates

Typically, you'll be adding content component item attributes to a content component template. This allows you to use the attributes in a content component Lava template, guaranteeing that it will be available every time a block is added to the page.

To get started we'll add an attribute category to the setup. Navigate to Admin Tools > General Settings > Attribute Categories and add a new category.

In the Name field, provide a name that is identical to the content component template name to which the attribute will apply. For example, enter "Hero" for attributes you'd like to add to the Hero content component template. In this case, the attributes would not be available to the "Card" or "Side By Side" templates. You only need to add one category for each content component template you have.

Next, select "Content Channel Item" as the Entity Type.

Now, add attributes to your newly-created category by going to Admin Tools > CMS Configuration > Content Channel Types and editing the Content Component entry to access its Item Attributes.

As pictured above, an item attribute for Image is already present. Click the ti ti-circle-plus icon to add a new Item Attribute.

When adding the new Item Attribute, use the Categories field to select the Content Component Template on which you'd like the attribute to appear. The rest of the setup is the same as any other attribute.

Same Attribute, Different Templates

Making a single attribute available across multiple templates is very similar to the process described above.

First, you'll repeat some of the above steps to create attribute categories for each content component template. Using what ships with Rock, that means adding "Side By Side" and "Card" categories in the same way that we added the "Hero" category. Then, when adding the attribute, you can select multiple categories (instead of just one) and the attribute will appear for each template according to your selection.

This method is the preferred way of adding attributes because it avoids duplication and prevents unnecessary attributes.

Adding an Attribute for All Content Components

Making an attribute available for all content components is easiest of all. Just like the scenarios described above, you'll start by navigating to Admin Tools > CMS Configuration > Content Channel Types. Edit the Content Component entry to access its Item Attributes.

Then, add a new attribute by clicking the ti ti-circle-plus icon as described above. The only difference here is that you'll leave the Categories field blank. Because a Category isn't specified, the attribute will be available for use with any template.