Blog, Highlight Current Category?

6 posts by 2 authors in: Forums > CMS Builder
Last Post: August 24, 2010   (RSS)

By zip222 - August 23, 2010

Related link: 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
Attachments:

code.php 2K

Re: [Jason] Blog, Highlight Current Category?

By zip222 - August 23, 2010

Thanks. Related question:

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

Hi,

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: [Jason] Blog, Highlight Current Category?

By zip222 - August 23, 2010

The latest, v2.05

Re: [zip222] Blog, Highlight Current Category?

By Jason - August 24, 2010

Hi,

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/