<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Menu option &amp;quot;active-branch&amp;quot; in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386982#M19625</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/74494"&gt;@jmgonzalez67&lt;/a&gt;, it looks like you solved this, but for anyone else viewing this question you can do something like the below. The advantage of this is that it requires no additional JS/jQuery, it can be all be done using HubL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set my_tags = blog_tags('default', 250) %}
&amp;lt;a href="{{ group.absolute_url }}" class="button{% if request.full_url == group.absolute_url %} active{% endif %}"&amp;gt;All&amp;lt;/a&amp;gt;
{% for item in my_tags|sort(False, False, 'name') %}
  &amp;lt;a href="{{ blog_tag_url(group.id, item.slug) }}" class="button{% if page_meta.html_title|split(' | ')|last == item %} active{% endif %}"&amp;gt;{{ item }}&amp;lt;/a&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: sorry, forgot to add "All" button&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 10:47:49 GMT</pubDate>
    <dc:creator>piersg</dc:creator>
    <dc:date>2020-11-17T10:47:49Z</dc:date>
    <item>
      <title>Menu option "active-branch"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386685#M19607</link>
      <description>&lt;P&gt;I have one menu in this blog:&lt;/P&gt;&lt;P&gt;&lt;A href="https://blog.strands.com/" target="_blank"&gt;https://blog.strands.com/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to mark the "All" option as active when we access the site and then deactivate it when we access any of the other options.&lt;/P&gt;&lt;P&gt;Thank you very much and best regards.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 12:39:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386685#M19607</guid>
      <dc:creator>jmgonzalez67</dc:creator>
      <dc:date>2020-11-16T12:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Menu option "active-branch"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386820#M19614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/74494"&gt;@jmgonzalez67&lt;/a&gt;&amp;nbsp;!&lt;BR /&gt;The ideal way to do this would be to edit your current function that does this to accomodate the All button too!&lt;/P&gt;
&lt;P&gt;If for any reason you can't do that one quick way of doing this would be by using the following code in your blog listing template, in the Additional markup before &amp;lt;/body&amp;gt; box on the right pane in the design manager.&lt;/P&gt;
&lt;P&gt;&amp;lt;script&amp;gt;&lt;/P&gt;
&lt;P&gt;{% if content.absolute_url == "&lt;A href="https://blog.strands.com" target="_blank" rel="noopener"&gt;https://blog.strands.com"&lt;/A&gt;&amp;nbsp;%}&lt;/P&gt;
&lt;P&gt;document.querySelector('#hs_menu_wrapper_module_1603711816926175_').children[1].children[0].className += "active active-branch";&lt;/P&gt;
&lt;P&gt;{% endif %}&lt;/P&gt;
&lt;P&gt;&amp;lt;/script&amp;gt;&lt;/P&gt;
&lt;P&gt;It's important to add this in the "before &amp;lt;/body&amp;gt;" tag, or otherwise to use a function that waits for the DOM elements to load, otherwise onload the styling would be overwritten.&lt;/P&gt;
&lt;P&gt;After checking your page I saw that the styling is applied by appending the active active-branch to your class - there's probably a few better ways of doing this, but that should work for now!&lt;BR /&gt;&lt;BR /&gt;Edit: as per&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386982/highlight/true#M19625" target="_blank" rel="noopener"&gt;reply below&lt;/A&gt; they list an ideal way to do this if you're editing your blog template or creating a new one using the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions" target="_blank" rel="noopener"&gt;blog_tags function&lt;/A&gt; - the fix above is specifically used as the set up uses a menu and no blog tag functions which I should have mentioned &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks for the advice&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 12:43:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386820#M19614</guid>
      <dc:creator>cathalhopper</dc:creator>
      <dc:date>2020-11-17T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Menu option "active-branch"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386935#M19621</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/119709"&gt;@cathalhopper&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I have tried what you tell me and I understand what your code has to do, but it still doesn't work.&lt;/P&gt;&lt;P&gt;Right now I have the code before the body, but as you can see, it does not work correctly.&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 08:32:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386935#M19621</guid>
      <dc:creator>jmgonzalez67</dc:creator>
      <dc:date>2020-11-17T08:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Menu option "active-branch"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386941#M19622</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/119709"&gt;@cathalhopper&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have finally been able to fix the problem.&lt;/P&gt;&lt;P&gt;I have modified your code a bit and now it works correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;script&amp;gt;&lt;/P&gt;&lt;P&gt;{% if content.absolute_url == "&lt;A href="https://blog.strands.com" target="_blank"&gt;https://blog.strands.com&lt;/A&gt;" %}&lt;/P&gt;&lt;P&gt;document.querySelector('#hs_menu_wrapper_module_1603711816926175_ ul').children[0].className += "active active-branch";&lt;/P&gt;&lt;P&gt;{% endif %}&lt;/P&gt;&lt;P&gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much and best regards!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 08:55:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386941#M19622</guid>
      <dc:creator>jmgonzalez67</dc:creator>
      <dc:date>2020-11-17T08:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Menu option "active-branch"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386982#M19625</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/74494"&gt;@jmgonzalez67&lt;/a&gt;, it looks like you solved this, but for anyone else viewing this question you can do something like the below. The advantage of this is that it requires no additional JS/jQuery, it can be all be done using HubL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set my_tags = blog_tags('default', 250) %}
&amp;lt;a href="{{ group.absolute_url }}" class="button{% if request.full_url == group.absolute_url %} active{% endif %}"&amp;gt;All&amp;lt;/a&amp;gt;
{% for item in my_tags|sort(False, False, 'name') %}
  &amp;lt;a href="{{ blog_tag_url(group.id, item.slug) }}" class="button{% if page_meta.html_title|split(' | ')|last == item %} active{% endif %}"&amp;gt;{{ item }}&amp;lt;/a&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: sorry, forgot to add "All" button&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 10:47:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Menu-option-quot-active-branch-quot/m-p/386982#M19625</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2020-11-17T10:47:49Z</dc:date>
    </item>
  </channel>
</rss>

