
Tom P
User

Jan 4, 2012, 10:24 AM
Post #2 of 3
(609 views)
Shortcut
|
|
Re: [kcmedia] Help with category menu
[In reply to]
|
Can't Post
|
|
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
|