Re: [buttermilk] category menu active page
Hi Ian,
It looks like you always have a list of all your records in $about_usRecords, and you have your selected record defined as $about_usRecord (no s). And when you loop over "all" the records in the foreach you refer to each individual record as $record. So you should be able to check if the menu link you are displaying is selected like this:
<?php if ($record['num'] == $about_usRecord['num']): ?>
selected
<?php endif ?>
That's basically saying, if the record we're displaying in the menu has the same record number as the selected record then print "selected".
It's a bit easier to read if you assign that to a variable. Here's some easier to read code:
<?php foreach ($about_usRecords as $record): ?>
<?php $isSelected = ($record['num'] == $about_usRecord['num']); ?>
<div style="display:inline; margin-right:5px;">
<?php if ($isSelected): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['name'] ?></a>
<?php else: ?>
<?php echo $record['name'] ?>
<?php endif ?>
</div>
<?php endforeach ?>
Hope that helps! Give that a try and let me know if you get any further, and any questions or problems with it.
Dave Edis - Senior Developer
interactivetools.com