Forum

Thread tagged as: Question, Runway

Using Perch If with Categories

Hi

Is it possible to use conditionals in templates using Perch categories?

For example:

<perch:categories id="testCat" set="cats">

<perch:if exists="catTitle" value="category1">
-- Show alternate content
</perch:if>

</perch:categories>

I know this means embedding knowledge of category titles in the template, but rather than make two calls on the master page to filter by categories, where we have a a list of articles that can be a mixture, the idea is that the template can conditional write specific elements based on this?

Vinay Jagessar

Vinay Jagessar 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes - but exists only checks if a value is set. Use id if you want to compare with a value.

Great, many thanks!