Linking categories, and creating hyperlinks to each

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

By degreesnorth - April 12, 2011

Hi

How would I link a category, and provide a hyperlink to this specific category. For example, I have a list of subcategories, each with just a title (for the name of that category). On the brand page, I want to be able to "tick" which of the subcategories this particular brand provides (provided as a checkbox list), and then provide a hyperlink to that specific category. Each brand could have one or more subcategories which it needs to link to.

When I just tried to create the first step, adding the code for the subcategories (Categories: <?php echo join(', ', getListLabels('brands', 'categories', $brandsRecord['categories'])); ?>, I got this message "PRODUCT categories: There was an error creating the list field. MySQL Error: Table 'menu_audio_com_au.cms_subcategories' doesn't exist", so I am kinda stuck. Yes, the "subcategories" list does exist - did I need to include the load records for subcategories in the header section as well?

Any help would be appreciated. Thx.

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: [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/