It took a while for me to get back to this, and attempt to get the menu items to be dynamic, but I’ve made some progress.
I've created a multi record editor called new_menu_categories with a title (used to populate the category 'entry' list field in the other table), a use_submenus check box, and link URL and Text fields to ultimately be used as the menu values if the check box is not checked
And a second multi record editor called new_subcategories with a list field to assign the record to a menu category, and a submenu-link_URL and submenu_link_text field for the drop down submenu values.
I’ve got the .js.php file to output the information in the correct format, but I’m getting repeats of all the categories in the viewer navigation menu.
There should only be one entry for each menu Category, but there are as many entries as there are records with that Category chosen as the entry value.
I’ve tried all the tricks that I know and I’m stuck as to how make this work correctly.
It should make more sense after looking at: http://www.artculturegroup.com/index30.php
Thanks,
Jerry Kornbluth
Here’s the new working code for the .js.php file.
<?php $output = ''; ?>
<?php
foreach ($new_menu_categoriesRecords as $record) {
// determine div class
$divClass = "";
if ($record['use_submenu'] == '1') { $divClass = "anylinkmenu"; }
// determine variable name
$entry = strtolower($record['title']);
// determine item list
$items = array();
if($record['use_submenu'] == 1){
foreach ($new_menu_subcategoriesRecords as $record)
if (strtolower($record['entry:label'])== $entry) { $items[] = array($record['submenu_link_text'], $record['submenu_link_url']); }
}
// output javascript
echo "var $entry = {divclass:'$divClass', inlinestyle:'width:150px; background:#DAD2D0', linktarget:''};\n";
echo "$entry.items = " . json_encode($items) . ";\n";
}
?>
And here’s the code for the viewer:
<table align="center" width="900px" border="0">
<tr>
<?php foreach ($new_menu_subcategoriesRecords as $record): ?>
<?PHP $spaced_entry = preg_replace("/[-_]/", " ", $record['entry:label'] ); ?>
<td width="16%" valign="top" align="center" ><a href="<?php echo strtolower($record['submenu_link_url']) ?>" class="menuanchorclass" rel="<?php echo strtolower($record['entry:label']) ?>"><span class="sub_heading_font"><?php echo $spaced_entry ?></span></a></td>
<?php endforeach ?>
</tr>
</table>
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php