I have created a bit of schema in a section for a collection picker field and I’m trying to output the url of the collection if possible. The collection picker has appeared in the settings and I’ve picked a collection but I can’t seem to output the url for it, here’s the code:
<div class="col-md-6">
<div class="category-box">
**<a href="{{ section.settings.category_top_left.url | default: "#" }}">**
<img src="{{ section.settings.category_top_left_image | img_url: '856x'}}" alt="">
<div class="content">
<h3>{{ section.settings.category_top_left_header }}</h3>
<p>{{ section.settings.category_top_left_text }}</p>
</div></a>
</div>
Schema:
{
"type": "collection",
"id": "category_top_left",
"label": "Category Top Left"
}
At the moment it’s the default that is being output, not sure where I’ve gone wrong.
This is the documentation I’m looking at for this – https://shopify.dev/docs/themes/liquid/reference/objects/section#section-settings
Thanks in advance.
2
Answers
If you have a look at Shopify Schema docs for Collection Picker, it states that
Since the output is the collection handle, you have to get the collection by handle and then get image, title or whatever is needed. Doing so, your code will be like
What it does is
request.path
is the answer.