For smart Primates & ROBOTS (oh and ALIENS ).

Showing posts with label Shopify. Show all posts
Showing posts with label Shopify. Show all posts

Saturday, November 30, 2024

Passing value in Shopify snippets and use it

Passing value in Shopify snippets and use it

You are working on Shopify project with a snippet. In that snippet you want pass value as per your need. So how can you achieve it ?

Let assume that you will use a snippet "rimg-a.liquid" in other liquid file and want to use as below. You want to pass imgurl, class and fetch value.

================================================

content of any liquid file or theme.liquid file in where you want to use rimg-a.liquid snippet file

include 'rimg-a',
        imgurl: 'URl-IMAGE',
        class: 'feature-mobile',
        fetch: 'yes'

================================================

content of rimg-a.liquid file

  <img  {% if fetch != blank %} fetchpriority="high" decoding="async" {% endif %} 
    {% if imgurl != blank %}
        src="{{ imgurl | split:'?' | first | replace: '2078x2233','390x419' }}"
    {% endif %}
    {% if class != blank %}class="{{ class }}"{% endif %}
  >

 

 

 

 

 

Share:

Tuesday, February 07, 2017

how to load javascript file from assets folder in shopify

How to load JavaScript file from assets folder in Shopify

We all already know that Shopify assets folder's path is random and unique name for each Shopify store holders. If you upload some graphics files or JavaScript files or any other files in your Shopify store's assets folder, then how can you identify it's real pah?

For this situation we can use "asset_url" keyword.

For image:

<img src="{{ 'myjavascript.jpg' | asset_url }}" />

For javascript file:
<script type="text/javascript" src="{{ 'myjs.js' | asset_url }}"> </script>


if you want to load only JavaScript file then you can also use this alternative
{{ 'filename.js' | asset_url | script_tag }}



 
So now we can say for other files we can modify the above code as per our requirements with keyword "{{ 'filename' | asset_url }}".



Share:

Monday, January 09, 2017

add comment in shopify

How to add comment in shopify

Using comment and endcomment tag you can add any one line multiple lines comments in Shopify code. below is the example:

{% comment %}

This is the comment in shopify

and this will not execute by shopify server because this is comment.

{% endcomment %}


Share:

Saturday, January 07, 2017

Shopify cache issue

Shopify Cache issue

You wondering that while working with Shopify e-commerce site code; your changes are not immediately showing; even your way of change code is right and there are no any error in your code.

No worry and no problem, it is not your fault or not your code issue. this is the issues with Shopify CDN cache. Normally Shopify clear his CDN cache files with in 3 to 4 hours to 1 day; but in some time it could be extends up to 3-4 days also(according to Shopify files). so wait till 4 days. After 4 days you will see your changes.


Share:

Ads Inside Post

Powered by Blogger.

Archive