Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Coding help with easy multi level nested list flyout menu

 

 


dbown
User

Oct 8, 2009, 3:29 PM

Post #1 of 6 (1664 views)
Shortcut
Coding help with easy multi level nested list flyout menu Can't Post

Hello,

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


Damon
Staff / Moderator


Oct 10, 2009, 8:53 PM

Post #2 of 6 (1627 views)
Shortcut
Re: [dbown] Coding help with easy multi level nested list flyout menu [In reply to] Can't Post

Hi,

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?

--------------------------------------------------- 
Cheers
Damon Edis
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/


Chris
Staff


Oct 11, 2009, 1:47 PM

Post #3 of 6 (1624 views)
Shortcut
Re: [dbown] Coding help with easy multi level nested list flyout menu [In reply to] Can't Post

Hi Dave,

You can use the following code to create a nested <UL> structure for your categories:


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


dbown
User

Oct 11, 2009, 8:12 PM

Post #4 of 6 (1619 views)
Shortcut
Re: [chris] Coding help with easy multi level nested list flyout menu [In reply to] Can't Post

Hi Chris,

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
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
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
Attachments: menu-structure.gif (24.8 KB)


Chris
Staff


Oct 13, 2009, 11:02 AM

Post #5 of 6 (1584 views)
Shortcut
Re: [dbown] Coding help with easy multi level nested list flyout menu [In reply to] Can't Post

Hi Dave,

Sorry, I should have mentioned that instead of getRecords(), you'll need to use getCategories() to make _listItemStart and _listItemEnd available.


Code
list($testRecords, $selectedTestRecord) = getCategories(array( 
'tableName' => 'test',
));


I hope this helps. Please let me know if you have any questions.
Chris


dbown
User

Oct 18, 2009, 2:00 PM

Post #6 of 6 (1546 views)
Shortcut
Re: [chris] Coding help with easy multi level nested list flyout menu [In reply to] Can't Post

Thank you Chris, that did the trick.

Cheers,
Dave