<p>The next step is that you would need to chain <code>.relatedTo(restaurant)</code> to your existing <code>craft.entries()</code> call</p>

CC BY-SA 4.0
2019-03-16T01:04:59.383Z
What would be the final snippet for this? I have problems to make it work.
Mark H.
CC BY-SA 4.0
2019-03-17T18:11:08.980Z
Anonyone please?
Mark H.
CC BY-SA 4.0
2019-03-15T14:28:11.340Z
2019-03-15T14:28:11.340Z
Yuri Salimovskiy
<p>What's given:</p>

<pre><code>Channel: Nutrition
Entries Fieldtype: restaurant
Category Fieldtype : menu

Category: Menu

Channel: Menus that also use relations using restaurant field.
</code></pre>

<p>Each item in the nutrition channel has restaurant and menu category selected.</p>

<p>On a restaurant's menu page I'm trying to list menu items from the nutrition channel grouped by categories.</p>

<p>Currently I use the following snippet</p>

<pre><code>            {% for category in craft.categories.group('menu').all() %}
                &lt;h3 id="{{ category.slug }}"&gt;{{ category.title }}&lt;/h2&gt;
                &lt;ul class="menu-items"&gt;
                    {% for entry in craft.entries.section('nutrition').relatedTo(category).orderBy('title').all() %}
                        &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
                    {% endfor %}
                &lt;/ul&gt;
            {% endfor %}
</code></pre>

<p>Which works fine. However if I add more nutrition items and assign them to another restaurant they'll be listed as well.</p>

<p>I assume we need to define restaurant first</p>

<pre><code>{% set restaurant = craft.entries.section('restaurant').one() %}
</code></pre>

<p>but what are my next steps?</p>

<categories><relations>
Relations and Categories
# Relations and Categories

(Asked by: username_0 on 2019-03-14)

What's given:
Channel: Nutrition
Entries Fieldtype: restaurant
Category Fieldtype : menu

Category: Menu

Channel: Menus that also use relations using restaurant field.

Each item in the nutrition channel has restaurant and menu category selected.
On a restaurant's menu page I'm trying to list menu items from the nutrition channel grouped by categories.
Currently I use the following snippet
            {% for category in craft.categories.group('menu').all() %}
                {{ category.title }}
                
                    {% for entry in craft.entries.section('nutrition').relatedTo(category).orderBy('title').all() %}
                        {{ entry.title }}
                    {% endfor %}
                
            {% endfor %}

Which works fine. However if I add more nutrition items and assign them to another restaurant they'll be listed as well.
I assume we need to define restaurant first
{% set restaurant = craft.entries.section('restaurant').one() %}

but what are my next steps?

**Tags:** categories, relations

---

## 1 answers

### Answer by username_1 on 2019-03-15. Score: 1

The next step is that you would need to chain `.relatedTo(restaurant)` to your existing `craft.entries()` call

> **Comments:**
> **username_0**: What would be the final snippet for this? I have problems to make it work.  
> **username_0**: Anonyone please?  

---

