Solved

Can you hide the "Mark_" prefix in Shopify filter list?

entranced
Explorer
66 1 13

Hi,

 

How can I hide the prefix "Mark_" in my filter list?

Namnlös.png

My filter code looks like this:

{% for tag in collection.all_tags %}
{% unless tag contains "Mark_" %}
     {% continue %}
  {% endunless %}

But dont know the syntax to hide the text Mark_ so it does not appear in the filter-list. I want it to look cleaner.

Hope someone can point me in the right direction.

Thanks!

 

Accepted Solution (1)
alexmarse
Shopify Partner
19 4 9

This is an accepted solution.

Ahhh word, this is helpful!

I believe that if you replace the {{ tag }}  just before the closing option tag at the end of your for loop with the original code I posted, that should do it.

So that line would now look like this:

<option value="{{ new_url }}"{% if current_tags contains tag %} selected="selected"{% endif %}>{{ tag | remove: "Mark_" }}</option>

 

Lemme know if that does the trick! Fingers crossed!

 

Alex Marse | Shopify Enthusiast
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!

View solution in original post

Replies 10 (10)

alexmarse
Shopify Partner
19 4 9

Hey @entranced ,

Thanks for your question!

I think the easiest way to do this would be to use the Liquid filter called remove. It allows you to remove a substring (like "Mark_") from your string ("Mark_Ardell").

Since you're already looping through your tags, all you would need to do is add the remove filter to the tag string within your for loop, like so:

 

{{ tag | remove: "Mark_" }}

 

Give it a shot and let me know how it goes!

Alex Marse | Shopify Enthusiast
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!
entranced
Explorer
66 1 13

Thanks for the response Alex, appreciate it a lot.

Should it be something like this?

{% for tag in collection.all_tags %}
{% unless tag contains "Mark_" %}
      {{ tag | remove: "Mark_" }}
     {% continue %}
  {% endunless %}

 

Don't really understand where to place that code snippet. 🙂 

alexmarse
Shopify Partner
19 4 9

Glad to be of service!

 

I think you would actually want to put it beneath the {% endunless %} , but still within your forloop.

 

Alex Marse | Shopify Enthusiast
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!
entranced
Explorer
66 1 13
{% for tag in collection.all_tags %}
{% unless tag contains "Mark_" %}
     {% continue %}
  {% endunless %}
    {{ tag | remove: "Mark_" }}

 

Alex, this didn't work. But I have a feeling that you are on the right track.

alexmarse
Shopify Partner
19 4 9

Ah shucks! Perhaps if you could send me the rest of the code that's on that page, I could see if there's something else going on that's causing that to not produce the desired result?

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!
entranced
Explorer
66 1 13

Own you one buddy. Thanks!

Here is my collection-filters.liquid

 

<div data-section-id="{{ section.id }}" data-section-type="collection-filters">
  {%- if section.settings.product_tags_enable and collection.all_tags.size > 0 -%}
    <div class="collection-sort">
      <label for="SortTags" class="collection-sort__label">{{ 'collections.sorting.title_tags' | t }}</label>
      <select name="SortTags" id="SortTags" aria-describedby="a11y-refresh-page-message a11y-selection-message" class="collection-sort__input">
        <option value="{{ collection.url }}">{{ 'collections.sorting.all_of_collection' | t }}</option>
 
        
        
        
        

                       

{% for tag in collection.all_tags %}
{% unless tag contains "Mark_" %}
     {% continue %}
  {% endunless %}
    {{ tag | remove: "Mark_" }}


        
        
          {%- assign new_url = tag | link_to_tag: tag | split: 'href="' | last | split: '"' | first -%}
          <option value="{{ new_url }}"{% if current_tags contains tag %} selected="selected"{% endif %}>{{ tag }}</option>
        {%- endfor -%}
      </select>
    </div>
  {%- endif -%}
  {%- if section.settings.product_sorting_enable -%}
    <div class="collection-sort">
      {%- assign sort_by = collection.sort_by | default: collection.default_sort_by -%}
      <label for="SortBy" class="collection-sort__label">{{ 'collections.sorting.title' | t }}</label>
      <select name="sort_by" id="SortBy" aria-describedby="a11y-refresh-page-message a11y-selection-message" class="collection-sort__input">
        {%- for option in collection.sort_options -%}
          <option value="{{ option.value }}"{% if sort_by == option.value %} selected="selected"{% endif %}>{{ option.name }}</option>
        {%- endfor -%}
      </select>
    </div>
  {%- endif -%}
</div>

{% schema %}
{
  "name": {
    "cs": "Kolekce",
    "da": "Kollektion",
    "de": "Kategorie",
    "en": "Collection",
    "es": "Colección",
    "fi": "Kokoelma",
    "fr": "Collection",
    "hi": "कलेक्शन",
    "it": "Collezione",
    "ja": "コレクション",
    "ko": "컬렉션",
    "nb": "Samling",
    "nl": "Collectie",
    "pl": "Kolekcja",
    "pt-BR": "Coleção",
    "pt-PT": "Coleção",
    "sv": "Produktserie",
    "th": "คอลเลกชัน",
    "tr": "Koleksiyon",
    "vi": "Bộ sưu tập",
    "zh-CN": "收藏",
    "zh-TW": "商品系列"
  },
  "settings": [
    {
      "type": "checkbox",
      "id": "product_tags_enable",
      "label": {
        "cs": "Povolit filtrování podle štítku",
        "da": "Aktivér tagfiltrering",
        "de": "Tag-Filtern erlauben",
        "en": "Enable tag filtering",
        "es": "Habilitar filtro de etiquetas",
        "fi": "Ota tunnisteiden suodatus käyttöön",
        "fr": "Activer le filtrage par balises",
        "hi": "टैग फ़िल्टर करना सक्षम करें",
        "it": "Attiva filtro tag",
        "ja": "タグでの絞り込みを有効にする",
        "ko": "태그 필터링 사용",
        "nb": "Aktiver taggfiltrering",
        "nl": "Filteren op tags inschakelen",
        "pl": "Włącz filtrowanie tagów",
        "pt-BR": "Habilitar filtragem de tag",
        "pt-PT": "Ativar filtragem por etiqueta",
        "sv": "Aktivera taggfiltrering",
        "th": "เปิดใช้การกรองแท็ก",
        "tr": "Etiket filtrelemeyi etkinleştir",
        "vi": "Bật lọc thẻ",
        "zh-CN": "启用标签筛选",
        "zh-TW": "啟用標籤篩選功能"
      },
      "default": true
    },
    {
      "type": "checkbox",
      "id": "product_sorting_enable",
      "label": {
        "cs": "Povolit řazení",
        "da": "Aktivér sortering",
        "de": "Sortieren erlauben",
        "en": "Enable sorting",
        "es": "Habilitar la función ordenar",
        "fi": "Ota lajittelu käyttöön",
        "fr": "Activer le tri",
        "hi": "क्रमबद्ध करना सक्षम करें",
        "it": "Permetti di ordinare",
        "ja": "並べ替えを有効にする",
        "ko": "정렬 사용",
        "nb": "Aktiver sortering",
        "nl": "Sortering inschakelen",
        "pl": "Włącz sortowanie",
        "pt-BR": "Habilitar organização",
        "pt-PT": "Ativar ordenação",
        "sv": "Aktivera sortering",
        "th": "เปิดใช้การจัดเรียง",
        "tr": "Sıralamayı etkinleştir",
        "vi": "Bật sắp xếp",
        "zh-CN": "启用排序",
        "zh-TW": "啟用排序功能"
      },
      "default": true
    }
  ]
}
{% endschema %}

 

alexmarse
Shopify Partner
19 4 9

This is an accepted solution.

Ahhh word, this is helpful!

I believe that if you replace the {{ tag }}  just before the closing option tag at the end of your for loop with the original code I posted, that should do it.

So that line would now look like this:

<option value="{{ new_url }}"{% if current_tags contains tag %} selected="selected"{% endif %}>{{ tag | remove: "Mark_" }}</option>

 

Lemme know if that does the trick! Fingers crossed!

 

Alex Marse | Shopify Enthusiast
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!
entranced
Explorer
66 1 13

Look at this beauty!

 

Namnlös.png

 

You did it! Thank you so much!

 

 

 

alexmarse
Shopify Partner
19 4 9

Awesome, glad I could help. Happy selling!

Alex Marse | Shopify Enthusiasts
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it Accept as Solution to help others locate the answer!
Your Like and Accept as Solution are much appreciated!
entranced
Explorer
66 1 13

Thanks a lot! Have a great weekend!