Cooking Recipes in Drupal 7

By Sil, 09/20/2011 - 09:12
Drupal Cooking Recipe - Pizza

Update: interested in doing food recipes with Drupal? Join the Drupal Group about rethinking food recipes in Drupal at https://groups.drupal.org/recipes-and-food.

The Drupal Recipe module is an easy way to add the ability to put cooking recipes on your Drupal 7 site. But.. :)

It has nice features like the quantity multiplier for Recipe scaling, Views support, Fields, and RDFa support.
It can automatically link to ingredient pages if you create the ingredient content type and use the ingredient's (exact) node title when entering it when adding the recipe.
It works great out of the box (just enable the module and off you go), and may be a good choice for you if you need to be able to add basic recipes to your site.

Currently the Drupal Recipe module is a very 'as is' solution.
We wanted stuff that is a bit more out of the (pizza) box, more flexible, more... how do I say... Ah yes: we want more :)
While not everything may be applicable to your own usecase (or the 'common' Recipe feature usecase), I believe a lot of the issues apply to 'regular' Drupal recipe sites.

Also I'd love to hear your thoughts and ideas, please comment below. 
Here are some of our thoughts about the Drupal Recipe module:

Automatic linking to the ingredient content type
The automatic linking works great, but has some limitations.
What if we want the recipe ingredient list to say '2 big mushrooms' and we already added the ingredient 'mushroom'.
We don't want to have two pages (one for mushrooms and one for mushroom), we want both ingredients to link to the same mushroom page.
And for the SEO fans: we want the entire 'big mushrooms' text to link to the mushroom page, because that makes our internal linking structure just a little bit more interesting.

And think about this usecase: an E-commerce site wants to link some ingredients to their product pages because they sell some of those ingredients.
'The company' already added their products to the Drupal Commerce store and want to link to them directly from their recipe page.
The Recipe module currently doesn't seem to be able to do that.

Fields and Views
The fields used by the Recipe module are all 'Recipe module element' fields.
Recipe Module Fields

This works great for the recipe module, but why not use 'existing' Drupal fields like the (long) text field for the Recipe content type. This would allow us edit field settings to suit the needs of a wider selection of usecases. Some may want certain fields as required, only allow certain input,  add a help text, apply custom_formatters, add Metadata mapping, etc. And the Recipe module would benefit from existing Views integration for all fields, and it could benefit from future efforts of the Measured Value Field or other modules that build on the Units API that are applicable to cooking recipes. Update: The Physical Fields module looks promising.
While outputting schema.org types as RDFa is possible through the schemaorg module our biggest concern was the ability to output schema.org types as Microdata.

RFDa and Microdata
The Recipe module has RDFa output, which is great. Google, Bing and Yahoo agreed on schema.org but not all search engines support schema.org types as RDFa completely (yet).
We want our recipes to appear in all search engines with a nice image, cooking time, etc. and let people find our recipes when searching for 'recipes with ingredient x' in (Googles) Recipe search.
So for us outputting schema.org's Recipe vocabulary as Microdata seems to be a 'must have'. Our fine Drupal community is building the Microdata module and it's way too good not to use.

Drupal Microdata for a Recipe

Because of the Recipe modules's choice to build its own fields instead of using existing fields currently there is no way to add microdata mappings to the Recipe module fields.

The Drupal Recipe module is a great module for doing a Drupal Recipe job, but I felt we (currently) needed something more of a Drupal Recipe Feature so we could better suit our recipe needs. I'm currently working on a Recipe Feature that has all of the above: the flexibility of linking to all kinds of content (and has the option to select that content through Views), 'regular' Field and Views integration, meta optimizations and it leverages the power of the Drupal community because it uses existing Lego blocks. The Recipe Feature uses field_collection, references (maybe relation), microdata and metatag. Fivestar with microdata support would also be a very nice to have addition.

The field_collection and Fivestar modules don't have microdata field formatter support at the time I'm writing this, and the Units API and Measured Value Field don't have (stable) Drupal 7 releases. Other than that I'm not seeing huge obstacles for trying to make Drupal cooking recipes as a Feature. We'll definitely learn a lot while atempting to take Drupal Cooking Recipes to the next level, and by the very least we'll succeed with the better part of it. smiley

Building on top of the Recipe module
What we're basically doing here is rebuilding the Recipe content type and extending it by combining it with other modules (configurations). This is because of the Recipe modules' inflexibility because of the 'Recipe module fields' choice. It would be great if the Recipe module would have a Recipe content type that was built with existing fields instead of 'Recipe module elements', so we can build the Recipe Feature with the Recipe module as a base.  I've opened an issue about the Recipe fields.
The next stop would be the current implementation of Recipe modules' ingredient selection. I feel this can be accomplished with field_collection + references/relation + Views in a more flexible way that makes linking to other content types possible (with different linking texts), wich could have huge benefits.

I'd love to hear people's thoughts and ideas on all of this.

Update 2011-11-21
As of today Fivestar module's dev release has some Microdata support!! 
And the Relation module looks very promising. It lets you build a build a relation from recipe to ingredient (like the Reference module can), and it also lets you put fields on that relation. This way you can put the 'amount' field on the relation. It has Views support including Views Relationships to the Relation (Entity) and the Ingredient node (the endpoint in this case) so you can show (and filter on) the 'amount' field(s). NodeOne has a great learning series about the Relation module.

The Physical field module looks promising, it might get support for Recipe related units too.


Have a look at the Drupal Group that discusses Drupal recipe goodness at https://groups.drupal.org/recipes-and-food