Forum
Conditionals on perch_content_custom
Hullo,
Wondering if it is possible to have some type of if/else statements on a perch_content_custom
call.
For example, I have a page that lists categories of Clearance products, with a select
field in the admin to choose the category. In the HTML page, there is a perch_content_custom
call for each category, like this:
<?php perch_content_custom('Clearance Items', array( 'filter'=>'p_clearance_group', 'match'=>'eq', 'value'=>'Construction' )); ?>
<?php perch_content_custom('Clearance Items', array( 'filter'=>'p_clearance_group', 'match'=>'eq', 'value'=>'Landscaping' )); ?>
<?php perch_content_custom('Clearance Items', array( 'filter'=>'p_clearance_group', 'match'=>'eq', 'value'=>'Rental Item' )); ?>
Nothing fancy – just checks for one of the three hard-coded categories and displays any listings in that group if it matches.
What I would like to do is be able to post a "No Clearance Items Available" message if there are no items in ANY of the categories. Of course, the region won't display at all if the filter/match
comes up with no results, so I can't use the if/else
conditionals in the template itself.
And that's about as far as I made it! Any suggestions would be helpful - thanks!
Sure, give something like this a go:
Sweet jebus, Drew - thanks!
Worked like a charm – clearly it's time to take some proper PHP courses so I can stop bugging you. :-)