Where Clause in Category List
3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 9, 2012 (RSS)
By InHouse - November 9, 2012
How do we limit which records to select in a Category query?
Would like to use a single Category list but with checkbox conditions so that a given record can be set to "show in main nav" and/or "show in footer" for menu use. Having two manual Category lists for this seems excessive.
Cheers,
J.
Would like to use a single Category list but with checkbox conditions so that a given record can be set to "show in main nav" and/or "show in footer" for menu use. Having two manual Category lists for this seems excessive.
Cheers,
J.
Re: [InHouse] Where Clause in Category List
There isn't a way you can use a where clause in the getCategories function. But you can get around this problem by differentiating between the two in the foreach loop instead. So you could use something like this:
Thanks!
<ul class="style6">
<?php foreach ($records as $record): ?>
<?php if($record['show_in_main_nav'] == '1'): ?>
<?php echo $record['_listItemStart'] ?>
<?php if ($record['_isSelected']): ?>
<strong>
<?php if (!$record['_hasChild']):?>
<a href="<?php echo $record['_link'] ?>">
<?php endif; ?>
<?php echo $record['name'] ?>
<?php if (!$record['_hasChild']):?>
</a>
<?php endif; ?>
</strong>
<?php else: ?>
<?php if (!$record['_hasChild']):?>
<a href="<?php echo $record['_link'] ?>">
<?php endif; ?>
<?php echo $record['name'] ?>
<?php if (!$record['_hasChild']):?>
</a>
<?php endif; ?>
<?php endif ?>
<?php echo $record['_listItemEnd'] ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
Thanks!
Greg Thomas
PHP Programmer - interactivetools.com
PHP Programmer - interactivetools.com
Re: [greg] Where Clause in Category List
By InHouse - November 9, 2012
Thanks Greg. That is the way I wound up doing it. Glad I wan't just missing something obvious (for a change).
Cheers,
J.
Cheers,
J.