Forum

Thread tagged as: Question

Trying to add category title to a div class

Hi

I'm trying to insert category results into a div class so that I can filter them with via jQuery isotope. I've been trying to adapt my template without joy and I'm wondering if its going to be possible? I currently have;

<perch:categories id="categories" label="Skills" set="skills" required="true" display-as="checkboxes">
<div class="team-card <perch:categories id="categories" set="skils"><perch:category id="catTitle" type="text" /> </perch:categories> ">
    <div class="team-card-text">
        <h2><perch:content id="text" type="text" label="Name" required="true" title="true" /></h2>
        <h3><perch:content id="text2" type="text" label="Job Title" required="true" title="true" /></h3>
        <h4>Skills</h4>
        <h5><perch:categories id="categories" set="skills">
            <perch:category id="catTitle" type="text" />
            </perch:categories></h5>
    </div>
    <div class="team-card-photo">
        <img src="<perch:content type="image" id="image" label="Associates Photo" width="75" height="100" crop="true" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="Enter the persons name again here" title="true" />" />
    </div>
    <div class="team-card-footer">
        <p>Click <a href="<perch:content id="text3" type="text" label="Page Link" required="true" title="true" />">here</a> to view the associates page</p>
    </div>
</div>

This is allowing me to select categories for the relevant person, but I'd like to then output these into the div class="team-card"

Am I trying something that isn't possible?

Thanks Wayne

Wayne Hooper

Wayne Hooper 6 points

  • 7 years ago

Your code will work but there's a typo, a missing 'l' on the skills set.

I would recommend outputting catSlug rather than catTitle however, just so it's hyphenated rather than spaced causing extra classes of course.

Hi Wayne, it works I have done it. You need to add the tag that allows the category to be outputted as html savvy.

this is what I mean here I think: https://docs.grabaperch.com/docs/templates/attributes/escape/ Good luck!

Argh I was so close. Thanks for spotting the typo Dexter and good call about the catSlug... works great now thank.

Thanks also Matthew for your link, the current solution is now working, but thanks for the suggestion.