Jump to content

Using $category in categoryTable


Meddysong

Recommended Posts

I need to personalise my output in a database template depending on whether a particular category is being displayed. I'm fine doing that with the Category Index template set because the index template contains the attribute $categories. Great!

Likewise, I could do it in the Listing template set because categoryHeader also contains the variable. Unfortunately, I need to place my code specifically in categoryTable, which doesn't have $categories as an attribute.

What do I need to do within that categoryTable to be able to reference the category? Once I'm able to do that, I'll be able to add a check to print some conditional code.

Link to comment
Share on other sites

I'm talking about the parent category; at this stage we're in the Listing template set and don't have any subcategories.

Here's my scenario, which should help make things clearer.

On my category index I list various roles within our organisation. In a few of those categories there are drop down arrows which, when clicked, list the records in that category.

Untitled-4.thumb.jpg.6e7288327aed617bd730b079685812bb.jpg

Those dropdown arrows appear because in the Category Index template set I'm able to use some conditional logic based on $categories. That feature also means I'm able to add a specific string to the bottom of one of those categories:

 Untitled-5.thumb.jpg.e51df0461e7c2e893f007f0392226d02.jpg

A simple bit of code accomplishes that for me:

{{if $catId==196}}<p class="cVolunteerMissing">Are you one of our volunteers and your name is missing? Contact us and we'll add you! You'll be able to edit the details after.</p>{{endif}}

(Earlier on in the template I run a foreach loop breaking down each $categories as $catId in order to pull this off.)

If the user clicks the category names rather than the dropdowns, then the default behaviour occurs and the Listing template set is called. Notice the difference?

1773669367_Untitled-5copy.thumb.jpg.fa7cb5c51aa8394927ee2ebcefa38c4a.jpg

What I'd like to do is have that same bit of text which appears in the category index also appear when you click on the name of the category and see the record listing. But to do that I need to be able to check that the visitor is seeing $category==196. And that's what I can't work out how to do from within categoryTable.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...