Output selected category

  • I have created a gallery where the images are allocated one or more categories.

    In the panel the editor uploads the image, the title of the image and selects the categories.

    This all works well but I can't work out how to output the selected category to the gallery page.

    I've tried all sorts of variations but this is the latest code.

    1. <perch:categories id="gallerycat" label="Select One or More Category" set="gallery" required>
    2. <div class="media-box <perch:categories id="gallerycat" label="Select One or More Category" set="gallery" required>">
    3. <div class="media-box-image mb-open-popup" data-src="<perch:content type="image" id="image" label="Image" width="1200"/>">
    4. <div data-thumbnail="<perch:content type="image" id="image" label="Image" width="800"/>" ></div>
    5. <div class="thumbnail-overlay">
    6. <div class="media-box-title"><perch:content type="text" id="imagetitle" label="Title" /></div>
    7. </div>
    8. </div>
    9. </div>

    I need the selected category names to show as a class next to the media-box class.

    Can anyone give me any pointers to a solution?

  • On line 3, next to 'media-box', do either of these work:

    <perch:categories id="catTitle"/>

    <perch:categories id="catPath"/>

    Also, on line 3, I don't think you need to repeat the label, set, or required within the perch:categoies tag. You can just include the id for simplicity.