Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Meddysong Posted May 24, 2018 Posted May 24, 2018 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.
opentype Posted May 24, 2018 Posted May 24, 2018 Are you talking about the parent category or the categories being listed in that template?
Meddysong Posted May 24, 2018 Author Posted May 24, 2018 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. 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: 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? 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.
opentype Posted May 24, 2018 Posted May 24, 2018 Okay. What you want is in the “container” of $table and $rows. So you can get IDs, names and so on like … {$table->container()->name} {$table->container()->id}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.