Restaurant Menu Builder

8 posts by 4 authors in: Forums > CMS Builder
Last Post: October 5, 2015   (RSS)

Hi Guys.

I want an administrator to be able to build menus for publishing on their website.

They would have a section of "Menu Items" which is really just a big list of items such as "Big Breakfast", "Poached Eggs", "Yoghurt", etc.

They would have a section of "Menus", where they would click "Create Record", give it a name like "Breakfast Menu" then be able to select "Menu Items" that they would want included in that menu.

However, they will need to be able to group the menu items (courses), and order the menu items as they like, so multiple menus may have similar items, but in a different order and under different courses ... so a menu could have;

Entree
- Soup of the day
- Dips

Main
- Steak
- Roast Chicken
- Vegetable Pie

Desert
- Ice Cream
- Jelly

I've create the various sections in CMSB, and have a lot more details such as prices, descriptions, variations etc - but I've realised that the actual building of the menus may need to be done outside of CMSB?

Cheers,

Tim (toledoh.com.au)

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

By Toledoh - October 2, 2015

Thanks Greg, but I'm not sure that will work.

I need a system to create multiple menus - so for instance, "Steak" could appear in the Lunch Menu, and the Dinner Menu, and "Betty's Wedding Menu" and "ACME Co Xmas Party Menu".  And "Steak" could appear under "Mains" in one menu, and under "From the Grill" on another menu.

The closest example I can think of is like an image library, where the site admin can refer to a library of images and add them as required, in different sizes, different positions and in different orders.  The main administrator would upload various approved images, and the section editors would be able to use those image.  In my case, the company approves various menu items, and controls descriptions, options, imagery etc for each of those menu items - then these items can be used to create a variety of menus as required.

I think it's a custom job, maybe using some kind of jQuery plugin that lists available items in one column, and allows the user to drag them into the menu they are creating?

Cheers,

Tim (toledoh.com.au)

By Dave - October 5, 2015

Hi Tim, 

So would it just be two levels, eg: Menus (Breakfast, Lunch, etc) and Menu Items (eggs, toast, steak, etc).  Or do you want to have more groupings/levels than that?

And what would be the easiest for the client, clicking on a menu and selecting all the items that apply, or going item by item and selecting the menus that apply? 

And how many menus and menu items?

Say you had 100 menu items and 3 menus.  One method would be to list all the menu items in their own table, then have the "Menus" table has a multi-value checkbox list of all the menu items so you could select which ones you wanted on each menu.  Another way the do it would be with a related records field.  

Let me know if you think either of those might work for you.

Dave Edis - Senior Developer
interactivetools.com

By Toledoh - October 5, 2015

Hi Dave.

No, there are 3 levels.;

1. Menus: There will be multiple menus, as we will actually be creating specific menus for group bookings, like a menu for the interactivetools.com Xmas Party.

2. Menu Section: Within each menu, there are groupings, like "Entree" and "Main" or "Curry's" and "Soups".  I would like the admin to be able to create these sections "on-the-fly", then apply menu items to each.

3. Menu Items: Individual menu items that have a name, description, price, photo/s, variations (rare, medium rare etc).  Only certain administrators will be able to edit these.

I may need to take this offline and get a custom programming job done, as I think it may be easier to manage it via the front end, rather than via CMSB?

Cheers,

Tim (toledoh.com.au)

By Dave - October 5, 2015

Hey Tim, 

You could do it in the CMS.  But it's always nicer with a custom front-end interface.  Here's a CMSB way: 

Sections for: 

  • Item Names (and photos, etc.  A list of available items to put on menu) 
  • Menus (menu name and related records field listing "Menu Items" for that menu num)
  • Menu Items (fields for: Menu Section [text], Item Name [pulldown or checkbox])

So you create a new "Menu" called "Breakfast".  You save and edit that, then under "Related Records" you click Add and enter (or select) the menu section, and select the food item.

Or if you wanted it simpler and you know you were never going to have more than 10 sections you could just have fields for Section 1 Name,  Section 1 Items, Section 2 Name, Section 2 Items, etc.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Toledoh - October 5, 2015

Hey Dave - that may work!  I could use the Show/Hide dependant fields to allow the user to say how many sections they have in the menu.  I'll try it out, thanks.

Cheers,

Tim (toledoh.com.au)