1

I am managing Tags in Craft. For example, I have a tag called Theme with entries Light, Dark, Grayscale, etc.

I want to be able to list all tag entries and then toggle their status on/off.

I have added Theme as a tag and created a field layout as shown below.

enter image description here

How can I now list the tags to access this field?

1
  • Did either of these answers help at all? Or is there something else we're missing?
    – Alex Roper
    Commented Feb 26, 2015 at 9:21

2 Answers 2

3

Depending on your needs, you may want to look into using categories instead of tags. Categories, like other entries, already have a status that can be turned on and off without creating a custom field. You can also manage categories thru their own section in the control panel like entries and assets.

Tags on the other hand, are kind of weird to manage in Craft. You can only add tags. You can't delete them without updating the database directly. And you can only add tags or update data in their fields by adding it to an entry, asset, or category.

Here's a screenshot below of how you would change the "oastatus" field for a tag that's been added to an entry. To do this, you would add the tag first, then double click on the tag to bring up this edit dialog of the tag's fields.

example of editing a tags custom fields

If tags is the way you want to go, and you want to display a list of tags and the 'oastatus' field you created with Twig in your templates, you can use the craft.tags ElementCriteriaModel:

<ul>
  {% for tag in craft.tags.group('theme') %}
    <li>{{ tag.title }} – {{ tag.oastatus }}</li>
  {% endfor %}
</ul>
2

Craft treats all element types as equal: assets, categories, entries, tags and users. This means that each of these element types can have their own set of custom fields.

In practice, you may well not need to create custom fields for things like tags or categories, but it's useful to be able to add them if you need to.

The field layout for a Tag is used for applying custom data fields to each tag, such as a description, not for storing the name of the tags.

To use tags in your Craft site, you must first create a tag group for each different group of tags you want to use.

Next, add a tags field and assign it to the entry types that you want to tag.

Now, when you are adding the content for each entry, you will be able to add a relation to the tag you want to assign to that entry by clicking the plus button in the tags field and typing the name of the tag you want to assign to the entry. As you type a pop-up menu appears showing you the matching existing tags in the system. The last entry in this menu adds the current typed name as a new tag to the group.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.