Linking categories, and creating hyperlinks to each

4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 14, 2011   (RSS)

Re: [degreesnorth] Linking categories, and creating hyperlinks to each

By Jason - April 13, 2011

Hi,

If you need the labels of the categories that were selected for a given brand record, you can use the :labels pseudo field. This will give you an array of those labels.

Try something like this:

Catgegories: <?php echo join(", ", $brandsRecord['categories:labels']);?>

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] Linking categories, and creating hyperlinks to each

By degreesnorth - April 13, 2011

I'll try that, but how do I hyperlink each of the categories? that is, so each of the categories is a link which goes to those pages?

Re: [degreesnorth] Linking categories, and creating hyperlinks to each

By Jason - April 14, 2011

Hi,

What you can do is create an array were we associate all the category values with category labels. We can then output these as links. Exactly how you format your links will depend on how you've set up your category page. Here is an example of how you could do it:

<?php $selectedCategories = array_combine($brandsRecord['categories:values'], $brandsRecord['categories:labels']); ?>

<?php foreach ($selectedCategories as $value => $label): ?>
<a href = "myCategoryPage.php?category=<?php echo $value;?>"><?php echo $label;?></a>,
<?php endforeach ?>


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/