Accessing title of selected submenu collection inside the collection page

Highlighted
New Member
3 0 0

Hello! 

The submenu and navigation I built workers great, it filters the category to subgroups based on their tags.

Here's the rub... the problem I'm having is I want to update the title of the page when you select a subgroup from the navigator. Right now it currently shows the name of the parent collection in the collection page and I can't seem to find out where to access the current link title on the collection page. 

Any advice on how to do this? Here's my current menu with sublinks code if that helps. 

<nav class="link-list" {{ block.shopify_attributes }}>

<h5>{{ linklists[block.settings.linklist].title | escape }}</h5>
<ul>
{% for link in linklists[block.settings.linklist].links %}
<li><a href="{{ link.url }}" {% if link.current %}aria-current="page" class="active" style="color:#05A4F7;font-weight:bold;"{% endif %} >
{{ link.title | escape }}
</a></li>
{% if collection.title == link.title %}
<ul style="text-indent:25px">
{% for sublink in link.links %} <li><a href="{{sublink.url }}" {% if sublink.current %}aria-current="page" class="active" style="color:#05A4F7;font-weight:bold;"{% endif %}> {{sublink.title | escape }}</a></li> {% endfor %} </ul> {% endif %} {% endfor %} </ul> </nav> 

 I tried using a similar linklist function to look for the current link for a title but I couldn't seem to get that to work either. 

0 Likes
Highlighted
New Member
3 0 0

I was able to get it by refactoring the same code above and comparing the current status of each link. Sorry I knew I was close but I'll leave this hear for anyone else with this problem and please let me know if there is a better solution. 

 

{% for block in section.blocks %}
              {% if block.type == 'menu' %}
                    {% for link in linklists[block.settings.linklist].links %}
              			{% if link.current %}
              				{{ link.title | escape }}
              			{% endif %}
                      {% if collection.title == link.title %}
                        {% for l in link.links %}
                         {% if l.current %}
                         	{{ l.title | escape }}
              			{% endif %}
                        {% endfor %}
                      {% endif %}
                    {% endfor %}
              {%endif %}
             {% endfor %}

 

0 Likes