Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Help with category menu

 

 


kcmedia
User

Jan 3, 2012, 4:34 PM

Post #1 of 3 (636 views)
Shortcut
Help with category menu Can't Post

Hi all

i have this category list on the home page at this site http://www.actionmc.com.au/beta/index.php for the accessories and i need to be able to have it built into cmsb i have created a category menu section but i cant get it work any ideas on what i need to do to make it work like i have it designed.

attached in the cmsb code and also the includes file for the design of the layout.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/httpdocs/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($accessories_menuRecords, $accessories_menuMetaData) = getRecords(array(
'tableName' => 'accessories_menu',
));

?> <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Accessories Menu - List Page Viewer</h1>
<?php foreach ($accessories_menuRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Parent Category: <?php echo $record['parentNum'] ?><br/>
Name: <?php echo $record['name'] ?><br/>
Link: <?php echo $record['link'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

<hr/>
<?php endforeach ?>

<?php if (!$accessories_menuRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
Thanks

Craig
KC Media Solutions
www.kcmedia.biz
Attachments: accessories-list.inc.php (1.50 KB)


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:

Code
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:

Code
         <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


kcmedia
User

Jan 4, 2012, 2:02 PM

Post #3 of 3 (600 views)
Shortcut
Re: [Tom P] Help with category menu [In reply to] Can't Post

Hi Tom

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

Craig
KC Media Solutions
www.kcmedia.biz