0

My site have a restaurant node type and each restaurant node has multiple menu items. Each menu item has food name, price , discount, etc.

What I want to do is creating a view that shows a list of all menu item node list which belong to a specific restaurant node.

Can anyone tell me how can I do that?

Thanks!

4
  • How are the food menu items saved in Drupal? Are they nodes?
    – Brady
    Dec 14, 2014 at 12:05
  • Yeah, both them are node Dec 14, 2014 at 12:10
  • Ok give me a few minutes. I think you can do this via relations in views
    – Brady
    Dec 14, 2014 at 12:13
  • How are you showing the restaurant node type? Are you using a node template for that?
    – Brady
    Dec 14, 2014 at 13:19

2 Answers 2

0

Install

Menu Node API

Manages relationships between node ids and menu items.

and Menu Node Views

The Menu Node Views module provides Views integration for nodes assigned to the menu system.

Create a view something like this:

View of Content (nodes)

Contextual filter:

  1. Add a contextual filter of Content: Nid

Fields:

  1. Content: Title, and exclude from display.

  2. Menu: Link title (The link text used for the menu item.)

Format: Unformatted list, with settings of Grouping field Nr.1 -> Content:title

That should do it.

This is not the only module solution available so research others as well.

1
  • Sorry, the menu in my question is the menu containing food name, price, discount. etc. Not the menu in Drupal navigation area. Sorry for confusing. Dec 14, 2014 at 7:30
0

You need to a function called views_embed_view.

1) Create an embed-type view display to display menu items. Assign a contextual filter for this view to be the referenced node (i.e. the id of the restaurant node).

2) Using a custom block that is shown only on restaurants' nodes, put these lines of PHP code (using PHP filter):

<?php
if ($node = menu_get_object()) {
 $nid = $node->nid;
}

print views_embed_view('view-name', 'views-display-name', $nid);
?>

That's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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