Using Flutter for a Restaurant Menu in WordPress

I want to share with you something technical that i’ve been working on in WordPress. (you don’t have to read this if you don’t want to I won’t be offended) Also, bear with me as I don’t usually write technically as much as I should. Here we go….

I’ve been making a website in WordPress for a local fine-dining restaurant.  Their food and wine is spectacular. Anyway, I made some custom CSS for the restaurant menu. Custom alignments for different data, etc. Not a problem for me to implement, but I needed a way for the restaurant chefs and managers to update the menu without messing with the code. I tried WYSIWYG editors, which made changing menu items fine, but adding menu items in would mess up half the time. So I decided to use custom fields with the plug-in Flutter.

However, local developer Tammy Hart has told me that soon, with the release of WordPress 3.0 that includes Custom Post Types, we might not need to rely so heavily on the plug in flutter for custom content types as we do now. That being said, I am still going to tell you what I found to be helpful in building a restaurant menu in flutter. But I thought you should know.

Here is the general CSS Layout that I’ve done:

I installed Flutter. I then made three “Custom Write Panels” – one for each kind of menu I have.

This makes a new items on the Admin Bar. I especially wanted this because the restaurant can “manage” and update their menus daily and wont have to dig far.

After I did that I made the specific custom fields for the Menu Item Name, The Item Description, and the Price. The three things I need to insert into my CSS to make each dish look right. And make a Field for the Name of the Grouping (appetizers, etc) at the bottom so that the restaurant can change “Entree” to “Main Course” if they want and so-on.

Now that we are all set with our fields, we can start making the template. Take your page.php file or other custom template file you have made, and after <?php the_content(”); ?> we need to call our fields.  According to Flutter’s Usage: to get one variable you use <? echo get(‘variable’); ?> to call.  However, in our menu items, we need to call duplicates. I started using getGroupDuplicates to call all the menu items, but I ran into a problem with the items that were deleted still showing up (bug?!). that is when I found This Thread .

In the file get-custom.php add this function:

/** Developed by Thang
* Return a array with the all distinct values in one array
*
* @param string $groupName
*/
function getDistinctGroupOrder($field_name){
global $post,$wpdb;
$elements  = $wpdb->get_results(“SELECT DISTINCT group_count FROM
“.RC_CWP_TABLE_POST_META.” WHERE post_id = “.$post->ID.” AND
field_name = ‘”.$field_name.”‘ ORDER BY order_id ASC”);
foreach($elements as $element){
$order[] =  $element->group_count;
}
return $order;
}
Than in my Custom Template I added the following (this is for the appetizers section):
<?php $group_orders = getDistinctGroupOrder(‘app-menu-item’);

foreach($group_orders as $group_order)
{ ?> <div id=”foodmenu”><dl>
<dt>
<?php echo get(‘app-menu-item’,$group_order,1); ?>
</dt>
<dd class=”price”>
<?php echo get(‘app-Item-price’,$group_order,1); ?>
</dd>
<dd class=”ingredients”>
<?php echo get(‘app-item-description’,$group_order,1); ?>
</dd>
</dl>
</div>
<?php }
?>

And then you just do the same for all sections on all templates and make sure that your field names match up.

However, I want to make this fool-proof. What if on the Special Menu, they did not want dessert? Setting up the template this way assumes that these are filled out. So, I have to set up a conditional statement so that I dont get a gap displayed with no items in it. Here’s how you do that- add this to your template file:

<!– check to see if there’s actually content filled in.  –>
<?php
$content = get_post_meta($post->ID, ‘d-item-name’, true); if ($content) { ?>

Then put in your flutter/template code in, and then add this at the end.

<?php } else { ?>
<?php } ?>

So for this “Dessert” Section, my code looks like this:

$content = get_post_meta($post->ID, ‘d-item-name’, true); if ($content) { ?>
<?php $group_orders = getDistinctGroupOrder(‘d-item-name’);
foreach($group_orders as $group_order)
{ ?> <div id=”foodmenu”><dl>
<dt>
<?php echo get(‘d-item-name’,$group_order,1); ?>
</dt>
<dd class=”price”>
<?php echo get(‘d-item-price’,$group_order,1); ?>
</dd>
<dd class=”ingredients”>
<?php echo get(‘d-item-description’,$group_order,1); ?>
</dd>
</dl>
</div>
<?php }
?>
<?php } else { ?>
<?php } ?>

All this does is checks to see if you have fields filled out. If you dont, it just moves on.

Here is what the Custom Write Panel looks like in your page editor:

Simple huh? You just duplicate the group to make more Entres. There are also the other panels there too (appetizers, desserts, etc) So the restaurant can now add and subtract Menu Items without any fear of messing up the custom CSS. And, with the way you can label things, you can make adding a menu item pretty intuitive. (no more non-labeled Custom Field box! “value”?! what does that mean?)

Anyway, it does takes a bit of effort, but it is worth it in the long run. I wont be getting calls every time they update something and messed it up. or don’t understand, etc. Flutter can be a bit clunky for beginners. (I was really scratching my head and wondering where all the simple documentation was located) But, there are some good articles out there. My friend Tammy Hart pointed me to this one on duplicate fields. And, I found this one to be helpful as well.

Here’s to the wait for WordPress 3.0. and Custom Post Types.  Till then, Flutter away!

- sara cannon

18 Comments

  • March 27, 2010 | Permalink | Reply

    Nice. Saw the tweet about Flutter, but couldn’t figure out what the flutter you were talking about. Thanks for spelling it out.

  • marian
    March 30, 2010 | Permalink | Reply

    Sara, I like this post! teach me teach me! Next post, how to learn word press?

    • Sara Cannon
      April 6, 2010 | Permalink | Reply

      Thanks Marian! Maybe I’ll make an intro to WordPress post soon. ;)

  • April 2, 2010 | Permalink | Reply

    Sara -
    Thanks for this article. I have been looking EVERY WHERE for a plugin to help create a simple menu system that is easily editable for clients but eliminates the risk of them destroying the design. I had the exact same problem with you when it came to clients messing up the menu when trying to add/delete items directly from the wordpress page itself. Flutter is good, but seems top heavy with respect to the simplicity of what I am looking to do. Like yourself, I will use it none the less until the release of either a new plugin to simply this task or WordPress 3.0. Thanks again!
    Chad

    • Sara Cannon
      April 6, 2010 | Permalink | Reply

      Thanks Chad. I was looking everywhere too. Glad I could help with what I found and good luck. :)

  • April 19, 2010 | Permalink | Reply

    Great article. I have used Flutter on another project before, it is actually a pretty powerful plugin, sadly it is limited by the amount of knowledge someone has of PHP and small amounts of documentation.

    I have played around with the Beta for WP 3.0 and I can tell you to achieve the results for this type of mini-project it is very simple and fun!

  • Sara Cannon
    April 20, 2010 | Permalink | Reply

    Thanks Brett. You’re right about the flutter documentation (that’s why I decided to write this.. spread the love) I’m excited about WP 3.0 and will be playing with the beta soon!

  • Mark Shaw
    June 8, 2010 | Permalink | Reply

    Thanks so much for the great information. This is the perfect solution. Only problem is, now I’m really hungry.

  • Ian
    July 11, 2010 | Permalink | Reply

    Hi Sara

    This is a great way to solve the problem.

    I’m looking at doing something similar at the moment using custom post types, but coding is not really my strong point. I would guess I’m probably at the same level as you in that I can do most things and understand them, but it doesn’t come as second nature and it’s not what I do all day.

    I’ve looked around and can’t find a plugin that’s made specifically for restaurant menus, so was thinking of having one developed and building it into a parent theme. I was just interested to know if you’d developed the idea any further with 3.0 and what you had found.

    Cheers
    Ian

    • Sara Cannon
      July 11, 2010 | Permalink | Reply

      Thanks for the comment Ian. I have started doing some custom post types / meta-boxes for another site. It is pretty fun but it seems to takes a bit of coding and isn’t so “out of the box” like flutter. A plug-in is a great idea and will save a lot of people headaches if they aren’t so advanced in their WP-Hacking skills. If you go for it, let me know. I’d love to check it out. :)

    • August 31, 2010 | Permalink | Reply

      Ian,
      I'm also looking into something very similar — maybe we could chat sometime about this? Shoot me an email at ripfishwarsaw(at)gmail.com sometime if you're interested!

  • wolf
    July 18, 2010 | Permalink | Reply

    Sarah – great post! Thanks a bunch!
    P.S. what's the restaurant called – in case I am in the area

    • Sara Cannon
      July 18, 2010 | Permalink | Reply

      Thanks! The restaurant is Veranda on Highland. :) It’s really great food. The wine selection is absolutely spectacular.

      • wolf
        July 20, 2010 | Permalink | Reply

        thank you – merci beaucoup! Love your work!

      • wolf
        July 20, 2010 | Permalink | Reply

        Also, Sara – what is the 'follow' plugin you are using on your blog (with the W and hover over function) … thx!

        • July 20, 2010 | Permalink | Reply

          Thank you very much! The commenting system is from Intense Debate using a plug-in. If a website has it installed, it will store all your comments in one place so you can see them all easy, and can "follow" your friend's comments on other blogs. :) It's really nice. I only installed Intense Debate just a few weeks ago here on sara-cannon.com and I really like it so far :)

          • wolf
            July 21, 2010 | Permalink |

            Great, thank you! I think I'll give it a try ….
            Have a great week!

  • Ben
    July 29, 2010 | Permalink | Reply

    Hello Sarah,

    Great post, thank you for sharing, I do have a friend wishing to have the exact same thing for his restaurant, I proposed my help but I am kind of stuck about the menu part in wordpress, I mean…I found your post here :-)
    I would like to ask you if you could send me the link of the site your worked on please so I can see a live demo of the work you have done if you don't mind. I can't wait to see how you managed to get this menu up and running on WordPress.

    Thank you so much!

    Ben

2 Trackbacks

  • April 5, 2010 | Permalink | Reply

    [...] The restaurant menus are not PDF’s! We built the menus using CSS and a plug-in called “Flutter” so that Veranda can easily update their menus without touching markup or worrying about formatting. We found this to be particularly important because their menu can change daily due to serving such fresh ingredients. Tech geeks: To read a post I wrote about how to use flutter for a restaurant menu go here. [...]

  • April 10, 2010 | Permalink | Reply

    [...] Using Flutter for a Restaurant Menu in WordPress – sara cannon Using Flutter for a Restaurant Menu in WordPress (tags: cms development plugins wordpress) Posted in Delicious bookmarks Cancel Reply [...]

Leave a comment

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Your email is never shared. Required fields are marked *

You can add images to your comment by clicking here.

Data Recovery Software