Assign different navigation menu to different pages

Assign different navigation menu to different pages

Orlando22
Tourist
16 0 1

I'm trying to assign a different menu and logo to page titles that contain specific words. If I change 'page.title' to 'template' the code below works... anybody know why this doesn't work for page.title? 

<ul class="nav mobile-site-nav">
{% if page.title contains 'stroller' %}
{% assign menu_handle = 'amababy-strollers-menu' %}
{% else %}
{% assign menu_handle = 'main-menu' %}
{% endif %}

Also, trying to figure out how I can assign a different logo based on the page title as well? 


Replies 3 (3)

Lucid_Polygon
Shopify Partner
349 63 96

The code looks right. Is your page title 'stroller'. Please display the page title on your page and confirm if the title is the same. Sometimes minor differences causes such issues.

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Orlando22
Tourist
16 0 1

Well the pages I want it to on do contain the word stroller although it's not the only word in the title. 

For example, I have 3 strollers and want it to apply to any page title with the word stroller in it, any product title with the word stroller in it and any collection title with the word stroller in it. 

I just did a test and realised the code works when I use == instead of contains but only if I use the full product title which means I'd have to edit the code everytime we introduce a new stroller. Is it possible to do this with tags maybe? I'm new to coding so still trying to wrap my head around it

 

Orlando22
Tourist
16 0 1

Just figured out that it is case sensetive, thank you for your help.