Forum

Thread tagged as: Question, Problem

Using Categories in Attribute/Navigation Templates

I seem to be having a bit of trouble with using categories in attribute and navigation templates. I can detect a category using perch:if, but I'm unable to get any information about that category (title, description etc). This is in my page attribute template:

  <perch:categories id="category" label="Category" set="course" />
    <perch:category id="catTitle" />
  </perch:categories>

I then use perch_pages_navigation to make a sidebar which has this in it:

<perch:if exists="category">
  <perch:category id="catTitle" />
  test
</perch:if>

It correctly detects that a category has been set (the word "test" appears on my page) but the category title doesn't appear. Is it possible to use perch:category template tags in navigation templates?

Thanks

Alan Longstaff

Alan Longstaff 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to use the perch:categories tag pair to output categories. So you'd have something like:

<perch:if exists="category">
  <perch:categories id="category" set="course" />
    <perch:category id="catTitle" />
  </perch:categories
</perch:if>

Ah makes sense - working now, thanks Drew :)