Hey Tim,
Do these items always appear under one menu item, or can they appear under more than one? (For example could Poached Eggs appear under both Breakfast and Brunch)?
If items can only appear under one menu item, then then setting up the menu system is fairly straightforward. You can set it up so that items always appear in the drag sort order used in the CMS:
<?php
// load viewer library
$libraryPath = 'cmsb/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
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 from 'blog'
list($blogs, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => false,
'leftJoin' => array('blog_categories' => 'category'),
'orderBy' => "blog_categories.dragSortOrder, blog.dragSortOrder",
'debugSql' => true
));
$blogsSorted = array_groupBy($blogs, 'category:label', true);
?>
<?php foreach ($blogsSorted as $categoryName => $blogs): ?>
<h3><?php echo $categoryName; ?></h3>
<?php foreach($blogs as $blog): ?>
<p><?php echo $blog['title']; ?></p>
<?php endforeach; ?>
<?php endforeach; ?>
This example code uses a blog categories section and blog posts, but the layout to the menu items/meals is the same.
So I've used leftJoin to get the blog_categories section so that I can get all of the data from those records as well. Then I use the array_groupBy function to group all of the menu items by their category.
Finally I use the two foreach loops to display the data, the first cycles through the categories, and the second cycles through the blog records.
Cheers,
Greg
Greg Thomas
PHP Programmer - interactivetools.com