0 like 0 dislike
asked in Sections Anywhere by (42 points)

After opening up Sections Anywhere for the first time I see the following warning on a section:


By clicking on the warning I, see more details:


Can you explain the nature of these errors?

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
answered by (42 points)
edited by

We create sections for the Sections Anywhere app by taking your existing sections and modifying them to work with the tools Shopify gives us.  As you might expect, the internal Shopify tools are more powerful than those given to app and theme developers.   This leaves us with several limitations.   They are as follows:

1.  We cannot create general objects in liquid.   We have to make due by creating multiple arrays and tracking the index.

2.  We are not able to save an image to the files API.  That means we cannot retrieve an image with properties like aspect_ratio, height, width and alt tag.

3.  There is no way to save a FALSE value in an array.   The best we can do is save a blank string.

4.  There is no way to save a number value to an array.  We can save a string representation of a number.

5.  We cannot namespace variables in sections vs blocks, so variables with the same name will be overridden.


In order to work around these limitations, we've come up with a few solutions:

1.  Since we don't have objects available, we are not able to use the section.blocks array.  Instead of:

    {% for block in section.blocks %}


    {% endfor %}

We use one of the repeating variables in the block to loop over:

    {% for atb_title0 in atb_title %}


    {% endfor %}

2.   We don't have an image object, so we are limited to what we can do with images and image filters.  Fortunately, we started saving image width, height, aspect ratio and alt into separate variables.   We also created an include file (atb-image) that handles all of the image filters with variables.  Instead of:

{{ section.settings.image | img_url: '600x600' | img_tag: section.settings.image.alt, 'feature-row__image' }}

We use:

{% include 'atb-image' image: atb_image, img_url: '600x600', img_tag: atb_image_alt %}

Anywhere you would see:





You'll want to use an underscore instead.  So if the image variable is named atb_image:





3.  If we have a checkbox field, the variable will not be saved as true/false.  Instead it is saved as "on" or "" (empty string).   To convert this variable to true/false we add the following:

{% if atb_show_product_info == blank %}

  {% assign atb_show_product_info = false %}

{% else %}

  {% assign atb_show_product_info = true %}

{% endif %}

4.  For a range slider variable, our value is saved as a numeric string.  To convert it to an integer we use the following code:

 {% assign atb_products_to_show = atb_products_to_show | plus: 0 %}

5.  Sometimes we must manually rename a variable to be unique.  Suppose we see two title variables, one for a sections and one for a block.  We must rename one from atb_title to atb_heading or similar.

Ask questions and receive answers from our expert developers and other members of the community.