Hi all,
The Collection List page has a header that you can set in the theme editor. I’m looking for a way to use that value elsewhere. In the code for the main-list-collections.liquid file, the variable used to call this value is section.settings.title…
#
{{ section.settings.title }}
…but I can’t access this variable elsewhere. I’d like to pass this value to a breadcrumb nav snippet that I’m calling from the theme.liquid file. This header value will be used (probably) exclusively on the product pages. I’m using the Dawn theme.
In my case, the header value for the Collection List page is the same as the label I gave to the menu item for that page (“All Collections”). So I could use that value too, if I could get it. I believe this value is buried in the linklists object, but I’m running into problems accessing deeper levels of this object. When I try outputting it to the console, I get errors:
Outputs:
Array(3) [ {…}, {…}, {…} ]
0: Object { error: "json not allowed for this object" }
1: Object { error: "json not allowed for this object" }
2: Object { error: "json not allowed for this object" }
length: 3
Thanks in advance for any help.
Zeb
Hi @ZebEllis ,
You can’t get value of section outsite it. You only can use “{{ section.settings.title }}” in sections/main-list-collections.liquid file.
If you want to add breadcrumb you can refer code below:
- {{ 'homepage.general.title' | t }}
{% if template contains 'product' %}
{% if collection %}
{% capture url %}/collections/{{ collection.handle }}{% endcapture %}
- {{ collection.title }}
{% endif %}
- {{ product.title }}
{% elsif template == 'article' %}
- {{ blog.title }}
- {{ article.title }}
{% elsif template == 'search' %}
- {{ 'general.search.search_title' | t }}
{% else %}
- {{ page_title }}
{% endif %}
/* Check linklist of menu use code below */
{{ linklists[‘main-menu’] | size }}
Hi @EBOOST , thanks for your reply. I can see that the value for section.settings.title is actually stored in the list-collection.json template file. I understand that this list-collection.json template file is used to control what is sections are rendered for the Collection List page, but the contents of the template file is simply a JSON object. Is there a way to load that object into a variable without treating it as an actual template?
My list-collection.json file:
{
"sections": {
"main": {
"type": "main-list-collections",
"settings": {
"title": "All Collections",
"sort": "alphabetical",
"image_ratio": "square",
"columns_desktop": 3,
"columns_mobile": "2"
}
}
},
"order": [
"main"
]
}
The data I need is right there. I just need a way to get it. I would really prefer not to hard code in a value that is user defined in the theme editor.
Also,
I’m not sure what you’re after here. This returns 3, which is strange because my menu actually has 4 items, one with a submenu of 5 items. Either way, I don’t need the size, just the ability to traverse the object.