Help with category menu

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 4, 2012   (RSS)

Re: [kcmedia] Help with category menu

By (Deleted User) - January 4, 2012

Hello Craig,

The first thing to look at is how the records are being retrieved - currently you're using "getRecords" which is perfect for general data but for categories there is a function "getCategories" that retrieves the data from the category table and preps it for use in creating a menu:
list($allCategories, $selectedCategory) = getCategories(array(
'tableName' => 'accessories_menu',
'categoryFormat' => 'twolevel', // showall, onelevel, twolevel, breadcrumb
));


Now we can use the $allCategories array to create the menu:
<ul>
<?php foreach ($allCategories as $category): ?>
<?php echo $category['_listItemStart'] ?>

<?php if ($category['_isSelected']): ?>
<b><a href="<?php echo $category['_link'] ?>"><?php echo $category['name'] ?></a></b>
<?php else: ?>
<a href="<?php echo $category['_link'] ?>"><?php echo $category['name'] ?></a>
<?php endif; ?>

<?php echo $category['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>


Setting "categoryFormat" to "twolevel" will show the root category (eg APPAREL) and then all the children of that category in an list 'below' it.

As long as the detail and viewer pages are set in cmsb (Admin->Section Editors->accessories_menu->Viewer Urls) then the links will automatically be set up.

Hope this helps,

Tom

Re: [Tom P] Help with category menu

By KCMedia - January 4, 2012

Hi Tom

thanks for that mate great help got it working 100%.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz