Shopify Remove all apps from home page
Wed Jul 20 2022 12:24:07 GMT+0000 (UTC)
Saved by
@mickeldav
#javascript
#shopify
{% if template.name == "index" %}
{% comment %} Leave url_to_remove as 0 to remove all apps, or set to a number to remove a specific app. {% endcomment %}
{% assign url_to_remove = 0 %}
{% assign lines = content_for_header | newline_to_br | split: '<br />' %}
{% for line in lines %}
{% if line contains 'var urls' %}
{% if url_to_remove == 0 %}
{% comment %}Remove all apps{% endcomment %}
{% capture new_line %}
{% endcapture %}
{% assign empty_array = new_line | append: "var urls = [];" %}
{% assign content_for_header = content_for_header | replace: line, empty_array %}
<!-- Removed all apps. -->
{% else %}
{% assign url_string = line | remove: "var urls = [" | remove: "];" | strip %}
{% assign url_array = url_string | split: ',' | uniq %}
{% comment %}Just remove app at index 'url_to_remove' {% endcomment %}
{% for url in url_array %}
{% if forloop.index == url_to_remove %}
{% assign content_for_header = content_for_header | replace: url, '""' %}
<!-- Removed app no. {{ url_to_remove }} of {{ url_array.size }}: {{ url }} -->
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{{ content_for_header }}
content_copyCOPY
Comments