Restricting Category Table to top 2 levels

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 23, 2013   (RSS)

By theclicklab - January 22, 2013 - edited: January 22, 2013

Hi there,

I have a list of yachts that are tagged to show in various destinations. The destinations table is setup as a "category" type so we have a hirachy of regions e.g. Caribbean > Windward > Grenada .

When we list yachts by type or in search results we also show the list of destinations thay are selected for. 

E.g. http://www.luxurychartergroup.com/search.php?destinations=4&type=catamaran

What I need to do its restrict this output to only the first two levels from the destinations category table rather than all of them.

Here is the code that is outputing the list:

<?php
$values = getListValues('yachts','destinations',$record['destinations']);
$labels = getListLabels('yachts','destinations',$record['destinations']);
$valuesToLabels = array_combine($values, $labels);
?>
<p class="destinations">Destinations:
<?php $count2=0; ?>
<?php foreach ($valuesToLabels as $value => $label): ?><?php echo ($count2==0)? "" : ", " ?><a href="/destination.php/<?php echo str_replace(" ","-",strtolower($label."-".$value)); ?>/"><?php echo htmlspecialchars($label); ?></a><?php $count2++;?><?php endforeach ?></p>

Many thanks
Jan

Attachments:

search_011.php 9K