Reputation: 61
I'd like to get a certain menu to display in the header on my product page instead of site-wide.
my theme.liquid
file has the {% section 'header' %}
tag within the <body>
so my header is showing fine on all pages as expected.
the sections/header.liquid
has the following schema:
{% schema %}
{
"name": "Header",
"settings": [
{
"type": "link_list",
"id": "menu",
"default": "main-menu",
"label": "Heading Navigation Menu"
}
]
}
{% endschema %}
I thought when you go into the theme editor on Shopify that you'd be able to individually select what shows up in the in menu part of my 'Heading Navigation Menu' section per page (Home, Collections, Blog, etc.), but at this point it's static. Ideally I'd be able to go in there and select a different menu I create in the Navigation setting for certain pages.
Upvotes: 0
Views: 1379
Reputation: 61
I ended up handling this with a switch statement and the template
object.
In my navigation bar in my sections/header.liquid
I created the switch statement:
<nav>
<ul>
{% case template.name %}
{% when 'article' %}
<li>
Show that
</li>
{% when 'cart' or 'blog' or 'product' %}
<li>
Show that and this
</li>
{% else %}
<li>
Show this
</li>
{% endcase %}
</ul>
</nav>
You can put whatever element you like inside of the individual cases and it will check whatever your template name is to put display that element.
Shopify documentation for both:
Not sure if this is the most effective way to do this, but hope this helps anyone trying to accomplish something similar.
Upvotes: 0