How to assign a liquid variable based on screen size?

New Member
1 0 0

Since liquid is server-side, and javascript client-side I can't figure out a way to do this:

if screensize < 768px

{% assign number_of_related_products_to_show = 3 %}

else

{% assign number_of_related_products_to_show = 4 %}

 

I'm sure there is way to accomplish this.  Any pointers?

 

0 Likes
Highlighted
Astronaut
1925 0 352

As you mentioned, Liquid is server-size and has no way of knowing the dimensions of the client's browser.

You might want to read up on grids and breakpoints, which make use of CSS media queries to adjust styles based on the width of the screen.

0 Likes