I want to be able to add menu's (the food kind) to my website. I have installed the CCK module and some others and this is what i am looking to do.

Create a new node type in the CCK with the following fields:

Menu Item (Starter - Soup)
Menu item description (very tasy soup indeed)
Menu item price (£1.00)

Now of cource if i were to creeate this custom node type i would only be able to add one iten to the node =/ not much of a choice in the menu. I wouls like to use this node type to add many items to my menu. So what i did was create this node type so that i can adda menu item to a certain category (christmas menu). By doing this i can then add all the menu items to one menu (category). I then created a view using the views module to display all the menu items associated with the menu category. As it stands, everything looks okay and when i click on the view "christmas menu" i get a listing of all the menu item node in one big list. but surely there is an easier way to accomplish the same result? something like createing a node type that allows me to fill in the custom fields many many time to create on node with all the menu items inside. Does that make sense? Well any feedback is appreciated =)

Haza

Comments

vincentc’s picture

Hi Haza,

As I see it, there are two ways to do what you need:

Method 1 - Create 2 new nodetypes: menu_item and menu

The concept is identical to what you did already:

a) Create a CCK nodetype called "menu_item".
b) Beside the title (mandatory CCK field), add 2 fields to this nodetype: description and price.
c) Create a CCK nodetype called "menu", which will simply be a container for your menu items.
d) Beside the title (mandatory CCK field), add a nodereference field to this nodetype. Set its properties so that it points to nodes of type "menu_item" only, and so it accepts multiple values (i.e. multiple menu items).

You may then order the menu items in whichever order you want (as you reference them). By adding several nodereference fields in your menu nodetype (each accepting several values), you could even have subsections in your menu (Starters, Main Courses, Desserts...).

However, you won't be able to display a menu as easily as you did with your solution, because you will have to customise the CCK template for menu nodetypes (see contemplate module) instead of using Views.

Method 2 - Create a custom CCK field

Create a custom CCK field called "menu_item" and give it 3 "sub-fields" : title, description, and price.
Once you have created the custom menu_item field, add it to the menu nodetype and make it accept multiple values.

This is quite an elegant solution, but it requires good PHP knowledge. Many CCK fields already implement this logic (e.g. http://drupal.org/project/link) so you can just copy/paste one of them and alter the code as needed.

The main shortcomings are that you'll have to order the menu items inside a menu manually, and you won't be able to reuse menu items in different menus (which you can do with method 1).

Hope it helps.

Vincent

Web Developer in Lille, France
Félisite, Création de sites Web Drupal, PHP, MySQL

Mac Clemmens’s picture

Thank you -- i am also in the same situation, using v5. I want to be able to add family members to the entity 'family'. All the solutions seems to be awkward. I want to just hit a [+] button and add a new family member. How does one add 'sub-fields'? Do I need a certain module? Thanks!

summit’s picture

Doesn't node_family.module work for you?
Greetings, Martijn