5
votes

Juan

Hello I was hoping a Shopify expert could advise me.

I already have a collections template in use and I need to prepare this layout to work within Shopify as something supplementary to the whole ecommerce function.

http://www.psd2htmlservice.com/streetstyles.jpg

As you can see you would click on the thumbnails and a larger corresponding image appears on the left along with some text at the top.

As I say there's no ecommerce element attached to this part of the site but I was thinking each image could be a product added to a collection. I'm well versed on looping through product images and collections but I'm not sure how to achieve the functionality required keeping in mind (as I understand it) you can't pass a value through the url in liquid. All I can think of would be to use a new page that uses a template with some liquid code hardcoded in each time....but surely there would be a more streamlined way.

I would appreciate any help.

Many thanks

2
Can you go into more detail about the particular problem you're running up against?David Underwood
Yeah sure.....I've already got a collections page all set up....corwin-group7120.myshopify.com/collections/women so this particular page in the screenshot is something extra.....following a different layout as well......I basically want to be able to loop through a different collection each time the relevant one is clicked through to on this "bespoke" page...I thought it could do it with a query string but it seems you can't in Shopify....any ideas would be much appreciated.Juan Chandler
Each collection in your shop has it's own page (e.g. collections/men, collections/women, collections/streetstyles) so you can link directly to those urls from another page to display the correct products. Is that what you're after?David Underwood
@juanchandler You have asked 9 questions on SO and this is the only place you have ever responded to any requests for more info. You have you ever Accepted any answer. That is very rude and inconsiderate of the people who take their time to HELP you for free.Andrew Steitz

2 Answers

7
votes

No, unfortunately you can not (as of June 2014)

There is a feature request called Expose current URL in Liquid for this but it has not yet been implemented.

Also, there are several older pages where this is asked on the Shopify help forms, probably the most direct is Pass variables to liquid template via URL which mentions:

You can't do this:

{{ request.myvar }}

to read myVal.

The common suggestions on the forums include:

  1. Using Javascript to read the URL and use it to modify the page or interact with the user,
  2. Create an application proxy which would be a page on your own server that it served up via a special link on your Shopify site (but it still does not actually allow you to access query variables in Liquid)
4
votes

Well, you can find it in liquid via {{content_for_header}} actually. Whether or not Shopify will remove from content_for_header in the future I can't answer, but you CAN get this in liquid.

{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}

{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
   replace:'\/','/' | 
   replace:'%20',' ' | 
   replace:'\u0026','&'
-%}

Check out this sample for how I've used this in the past: https://www.channelape.com/shopify/build-custom-json-api-shopify-liquid/