Using conditionals in module layouts to list Global Tags by headings
Global Tags are useful for assigning values in custom fields used for classification, such as a field for 'Skills' listed on Membership profile detail pages, or any field used for classification of Tags for items in a custom directory. This article shows you how to use conditionals properly in your Module Layouts so that each classification field functions as a heading that will only appear if there are one or more Tags assigned in the corresponding field.
In simplest terms, this is what we wish to accomplish: "If there are Tags, display a Tag heading and list the Tags, or else don't show anything."
For an example, let's assume that there are three custom fields used for classifying and displaying Tags on a member's profile page, which uses the Membership Module Layout labeled "[Detail]", and these will be used as the headings:
Each of the above classification fields has an associated Tag Module Layout:
Continuing with the Membership example, in the Membership [Detail] module layout, we insert each of the above Tag layouts one after the other, like so:
Then, we simply go into each of the relevant Tags module layouts themselves, and in the 'Body' section of the layout, write in a conditional similar to the following:
Ensure that the 'Item' section of each of the Tags module layouts displays the following (which should be present by default):
Repeat for each of the Tag layouts, and each Tag heading along with existing Tags will only display if there are Tags specified for it,