twigopencart-3

How to hide an element only in homepage?


Trying to do "if homepage hide " a button.

Current code is here...

  <div class="mobile-bar sticky-bar">
            {% if j3.settings.get('mobileCustomMenuStatus1') %}
      <a class="mobile-custom-menu mobile-custom-menu-1" href="{{ j3.settings.get('mobileCustomMenuLink1.href') }}" {{ j3.linkAttrs(j3.settings.get('mobileCustomMenuLink1.attrs')) }} style="margin-left:10px; margin-right:-30px">
        {{ j3.countBadge(j3.settings.get('mobileCustomMenuLink1.name'), j3.cache.update(j3.settings.get('mobileCustomMenuLink1.total')), j3.settings.get('mobileCustomMenuLink1.classes')) }}
      </a>
      
      {% endif %}
      {% if j3.settings.get('mobileCustomMenuStatus2') %}
      <a class="mobile-custom-menu mobile-custom-menu-2" href="{{ j3.settings.get('mobileCustomMenuLink2.href') }}" {{ j3.linkAttrs(j3.settings.get('mobileCustomMenuLink2.attrs')) }}>
        {{ j3.countBadge(j3.settings.get('mobileCustomMenuLink2.name'), j3.cache.update(j3.settings.get('mobileCustomMenuLink2.total')), j3.settings.get('mobileCustomMenuLink2.classes')) }}
      </a>
      {% endif %}

Solution

  • You can store the current page within a $data variable in your menu controller just like this:

    $data['current_url'] = $_SERVER['REQUEST_URI'];
    

    Within your twig file you can check it's value against whatever you want. This can be achived using a small vqmod or ocextension.