Reputation: 31
I'm theming the basic stuff for a webshop and trying to add a 'view collection'-button to the featured collection on the home page. In the documentation it states that normally I just need to do collection.url and get the url. But it doesn't seem to work. Can someone say what I do wrong? (https://help.shopify.com/themes/liquid/objects/collection#collection-url)
{% if section.settings.show_view_all %}
<hr class="hr--clear">
<div class="text-center">
<a href="{{ section.settings.featured_collection.url }}" class="btn">
{{ 'collections.general.view_all' | t }}
</a>
</div>
{% endif %}
</div>
{% schema %}
{
"name": "Featured collection",
"class": "index-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Featured collection"
},
{
"type": "collection",
"id": "featured_collection",
"label": "Collection"
},
Upvotes: 0
Views: 1166
Reputation: 19
I wrapped the h2 tag like this:
{% if section.settings.title != blank %}
<a href="/collections/{{ section.settings.home_page_featured_products }}"><h2 class="small--text-center">{{ section.settings.title | escape }}</h2></a>
{% endif %}
As I do not ever plan to make the collection slug different, this works for me. Your mileage may vary. This is using the 'Simple' theme.
Upvotes: 1
Reputation: 294
You should check the collection setting type: https://help.shopify.com/themes/development/theme-editor/settings-schema#collection:
The output of the option the merchant selects from the drop-down is the handle of the collection.
So, instead of:
{{ section.settings.featured_collection.url }}
you should use:
{{ collections[section.settings.featured_collection].url }}
Upvotes: 0