0

We use Commerce - and there we have the problem with the search or e.g. the language changer, because we work with "entry" and Commerce does not know that. Does anyone know how we can solve this?

Code for language-switcher:

<div class="list-wrapper">
  <div class="lang-changer">
    {% if entry is defined %}
      {% for siteForEntry in entry.getSupportedSites %}
        {% set site = craft.app.getSites.getSiteById(siteForEntry.siteId) %}
        {% if site.id == entry.siteId %}
          <p class="active-language f-blue">{{ site.handle }} </p>
        {% endif %}
      {% endfor %}
  </div>
  <ul class="language-list">
    {% for siteForEntry in entry.getSupportedSites %}
      {% set site = craft.app.getSites.getSiteById(siteForEntry.siteId) %}
      {% if site.id != entry.siteId %}
        <li>
          {% set entryForOtherSite = craft.entries.id(entry.id).site(site).one() %}
          {% if (entryForOtherSite is defined) and (entryForOtherSite is not null) %}
            <a class="inactive" href="{{ entryForOtherSite.getUrl() }}">{{ site.handle }}</a>
          {% else %}
            <span class="unavailable">{{ site.handle }}</span>
          {% endif %}
        </li>
      {% endif %}
    {% endfor %}
  </ul>
{% endif %}
</div>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.