Blog, Highlight Current Category?
6 posts by 2 authors in: Forums > CMS Builder
Last Post: August 24, 2010 (RSS)
By zip222 - August 23, 2010
http://www.lppacs.org/thebeat/
In the "Announcements" area of the page, could you tell me how to highlight the active category?
A file with the relevant code is attached.
thanks
Re: [zip222] Blog, Highlight Current Category?
By Jason - August 23, 2010
You can change the code that outputs your categories like this:
<?php foreach ($categoriesRecords as $record): ?>
<li>
<?php if($record['num']==@$_REQUEST['category']): ?>
<b>
<?php endif ?>
<a href="index.php?category=<?php echo $record['num'] ?>"><?php echo $record['title'] ?></a>
<?php if($record['num']==@$_REQUEST['category']): ?>
</b>
<?php endif ?>
</li>
<?php endforeach ?>
This code example uses a <b> tag to make the selected category bold. You can change this to use any HTML or CSS you want.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Blog, Highlight Current Category?
By zip222 - August 23, 2010
In the left column where the announcements appear, how do I make those category tags links? The earlier attachment includes this code as well, but here it is as well:
<?php foreach ($announcementsRecords as $record): ?>
<li>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
Posted <?php echo date("M j, Y", strtotime($record['publishDate'])) ?> | <?php echo join(', ', getListLabels('announcements', 'category', $record['category'])); ?>
</li>
<?php endforeach ?>
Re: [zip222] Blog, Highlight Current Category?
By Jason - August 23, 2010
There are a couple ways of doing that. What version of CMS Builder are you using. The version will determine the easiest method of doing this.
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [zip222] Blog, Highlight Current Category?
By Jason - August 24, 2010
Give this a try:
<?php foreach ($announcementsRecords as $record): ?>
<li>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
<?php
$categories=trim($record['category'],"\t");
$categories=explode("\t",$categories);
$catList=array();
foreach($categories as $category){
$categoryLabel = getListLabels('announcements','category',$category);
$catList[]="<a href=\"?category=$category\">".$categoryLabel[0]."</a>";
}
?>
Posted <?php echo date("M j, Y", strtotime($record['publishDate'])) ?> |<?php echo join(', ',$catList) ?>
</li>
<?php endforeach ?>
This code creates an array of links and then outputs them. Let me know if you run into any issues with that.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/