Coding help with easy multi level nested list flyout menu
6 posts by 3 authors in: Forums > CMS Builder
Last Post: October 18, 2009 (RSS)
By dbown - October 8, 2009
I would like some help creating a multi level nested list flyout menu.
I have attached a screenshot of my category menu structure as taken from within CMS Builder.
If you visit the following link I have a working example of the menu that I would like to produce. It has the exact same menu hierarchy as my CMSBuilder categories. This navigation menu (at the top of the page) is currently hand coded.
Link: http://www.canadasprayerguide.com/WebsiteCMS/menutest.php
Below the hand coded menu I have a simple code dump from CMS Builder that generates a visual listing of all the entries. The code used for this is as follows:
<?php foreach ($testRecords as $record): ?>
Parent Category: <?php echo $record['parentNum'] ?><br/>
Name: <?php echo $record['name'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<hr/>
<?php endforeach; ?>
<?php if (!$testRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
Can you please help me with the coding required to convert my CMS Builder categories into an accurate nested list menu layout. Essentially reproducing the working flyout navigation menu on the top of the page with CMS Builder generated code?
Best Regards,
Dave
Re: [dbown] Coding help with easy multi level nested list flyout menu
By Damon - October 10, 2009
The screenshot wasn't attached and it would be helpful to see how you have the categories setup in CMS Builder, can you attach it?
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [dbown] Coding help with easy multi level nested list flyout menu
By Chris - October 11, 2009
You can use the following code to create a nested <UL> structure for your categories:
<ul>
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?>
<b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
<?php else: ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endif; ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
I hope this helps! Please let us know if you have any questions.
Chris
Re: [chris] Coding help with easy multi level nested list flyout menu
By dbown - October 11, 2009
Thanks for hte help.
I've tried adding the attachment again. If it doesn't work it can also be seen at
http://www.canadasprayerguide.com/WebsiteCMS/menu-structure.gif.
I added your code but received an error.
It can be seen at Link: http://www.canadasprayerguide.com/WebsiteCMS/menutest2.php
The header code is as follows:
<?php
require_once "/home/canadasp/public_html/cmsAdmin/lib/viewer_functions.php";
list($testRecords, $testMetaData) = getRecords(array(
'tableName' => 'test',
));
?>
I changed the first line of your code to so match my category name. It now reads as follows:
<?php foreach ($testRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?>
<b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
<?php else: ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endif; ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
This version also produces and error that can be seen at Link: http://www.canadasprayerguide.com/WebsiteCMS/menutest3.php
Any further help that you can provide would be most appreciated.
Best Regards,
Dve
Re: [dbown] Coding help with easy multi level nested list flyout menu
By Chris - October 13, 2009
Sorry, I should have mentioned that instead of getRecords(), you'll need to use getCategories() to make _listItemStart and _listItemEnd available.
list($testRecords, $selectedTestRecord) = getCategories(array(
'tableName' => 'test',
));
I hope this helps. Please let me know if you have any questions.
Chris
Re: [chris] Coding help with easy multi level nested list flyout menu
By dbown - October 18, 2009
Cheers,
Dave