Different Menus for Different Set of Pages

bradrlyons
Visitor
3 0 0

I'm using the Dawn theme to create a site that has B2C and B2B menus. The home page is the B2C landing page with B2C menu. They can click a link that will take them to a B2B landing page and I need to have a different menu for that. Both menus have sub pages.

I've tried the following code in the header.liquid section: 
{% if page.handle contains "business-to-business" %}
{% assign menu = 'b2b-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 %}

 

That works, but it obviously creates a new, non-stylized menu ontop of the standard menu. Is there a way to call out the B2B menu in a different file so it just replaces the standard menu for the B2B pages? Or do I need to paste over code within the header.liquid?

Replies 0 (0)