0

Currently I am making a advertisement website for restaurants. Now I am putting the restaurant basic information (name, address,etc) in a node.

What I want to do is making a menu list for the restaurant, Say each menu item is a node (with the type of 'item') while the restaurant is another node type 'restaurant'.

In database level, the relationship between node (restaurant) and menu item node type is one-to-many.

So how can I do this?

Thanks for any help!

Cheers!

  • What version of Drupal? – calebtr Dec 13 '14 at 9:39
  • The version of my Drupal is 7.34 – user3110099 Dec 13 '14 at 9:41
  • Are you sure that you would like a whole node for each menu item? If the menu item were just a title, or title with price, this might be overkill, you could instead use a field with multiple values, or a field collection – autopoietic Dec 13 '14 at 12:15
2

Install the references module, once you done that, you can enable the node_reference submodule and attach a "Node Reference" field to your "restaurant" content type.

Next, set the "item" content-type as reference for the field and the "Number of values" setting as "Unlimited".

When creating or editing a restaurant, you should now be able to link multiple menus to the node.

  • Thanks for posting! But I made it to add a menu item to the 'restaurant' node, however I want to add multiple menu items to one 'restaurant' node. Is it possible to do that? – user3110099 Dec 13 '14 at 11:30
  • Isn't the solution I provided already doing what you want? I gave you a way to link unlimited node "item" to a restaurant. Once the restaurant is saved, you can generate a list of all menus from a view or using code. Maybe I'm missing something? – thedotwriter Dec 13 '14 at 11:40
  • Or is it that you want to create an "item" node while on a restaurant edit form? If that's what you want, there's a way but the solution I'm talking about now is based on the idea that "item" nodes already exist before coming to the "restaurant" node form. – thedotwriter Dec 13 '14 at 11:57
  • Yes! This is exactly what I want. I finally made it to attach multiple nodes to the restaurant node. Thanks for your time! – user3110099 Dec 13 '14 at 12:21
  • That's cool :) But before implementing that, make sure you really need a node for each menu item. As autopoietic said, if you don't need to do anything complex with those values, a well configured field collection into the restaurant content type should be enough ;). – thedotwriter Dec 13 '14 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.