Re: use 2 different menus on 2 different pages

use 2 different menus on 2 different pages

love666
Tourist
9 0 6

Hello,

 

I have a problem with my menus, i have created two different menus lets call them women and kids. When i assign the menu kids to the kids page, the menu changes on all other pages like womens page. I want to use specific menu for each page. I have tried to look into the coding part but i cant find where i need to change the coding, closest i got to was it displayed both menus at the same time.

 

{% if customer.tags contains "wholesale" %} {% assign menu = 'wholesale-menu' %} {% else %} {% assign menu = 'normal-menu' %} {% endif %} {% for link in linklists[menu].links %} //code to output your menu items. {% endfor %}

 

maybe this code will work if i insert it into nav.liquid or header, but i need to change {% if customer.tags contains "wholesale" %} to something specific for the page

Replies 11 (11)

Savior
Shopify Partner
537 108 161

Hello

 

You can use

{% if page.handle contains "kids" %}

Kids menu

{% elsif page.handle contains "womens" %}

Womens menu

{% else %}

common menu

{% endif %}

Use your page handles, you can find it in your URL: myshopify.com/pages/page-handle

banned
love666
Tourist
9 0 6

Thanks, which liquid file do i put this code into?

Savior
Shopify Partner
537 108 161

@love666 

You can check where your menu code has been added. Maybe header.liquid or any nav.liquid file.

banned
love666
Tourist
9 0 6

alright thanks, the womens page doesnt have handle since its the first page (home page) what do i write instead?

Savior
Shopify Partner
537 108 161

@love666 

 

Use below code

{% if page.handle contains "kids" %}

Kids menu

{% else %}

common menu for all other pages

{% endif %}

 

banned
love666
Tourist
9 0 6

I tried your code but then on my website i can only see the text kids menu on top not showing the actual menu. I tried this, i think you missed a part of code where it says assign, but this didnt have any effect on the site

 

{% if page.handle contains "kids" %}

{% assign menu = 'kids-menu' %}

{% else %}

{% assign menu = 'main-menu' %}

{% endif %}

Savior
Shopify Partner
537 108 161

No i haven't missed any code. You have to access your menu in between the conditions like below.

 

{% if page.handle contains "kids" %}

{% assign menu = 'kids-menu' %}

<ul>

{% for link in linklists[menu].links %}

<li>

<a href={{ link.url }}>{{ link.title }}</a>

</li>

{% endfor %}

</ul>

{% else %}

{% assign menu = 'main-menu' %}

<ul>

{% for link in linklists[menu].links %}

<li>

<a href={{ link.url }}>{{ link.title }}</a>

</li>

{% endfor %}

</ul>

{% endif %}

banned
Elie-Mrad
Shopify Partner
7 0 0

Hello,

 

This code is perfect, but where should it be placed once I add it to the code, it shows double menus, the original one in place and this code to the upper left vertically

 

ElieMrad_0-1701094735026.png

 

 

saraelizpor
New Member
15 0 0

Did you find a solution to this? It's showing double menus for me also.

Vassia_Sarri
Tourist
4 0 0

Thank you, I have been looking for this for ages, and looks like no one else knows how this should be done. Can I ask, If my "Pages" that need different menu are actually Categories and also Product - pages, instead of page.handle should I write category.handle  and product.handle?

gr_trading
Shopify Partner
2045 149 206

Hey @love666 ,

 

I know i'm bit late into it but please refer to the below video to implement the same.

 

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee