I'm trying to set the overlay header on some pages where the overlay header is not a standard setting on my Motion theme of my Shopify store.
This is the store link: https://hatproof.com/
I premise that I'm not very good on liquid code, and I'm asking here for help.
This are the original code lines:
assign template_name = template | replace: '.', ' ' | truncatewords: 2, '' | handle
assign sticky_header = false
assign overlay_header = false
if section.settings.header_sticky
assign sticky_header = true
endif
if template_name == 'index' and section.settings.sticky_index
assign overlay_header = true
endif
if template_name == 'collection' and collection.image and section.settings.sticky_collection
assign overlay_header = true
endif
I've try to edit adding this on the bottom:
if template_name == 'page.chisiamo'
assign overlay_header = true
endif
But the "overlay_header" value of the page https://hatproof.com/pages/nuovo-chi-siamo ('page.chisiamo' template name) hasn't changed to "true".
I've also try to edit the variable name in 'page', 'page chisiamo' but never worked.
This is how the value is used:
<div data-section-id="{{ section.id }}" data-section-type="header">
<div id="HeaderWrapper" >
What can I do to change the "overlay_header" value to true of some specific pages?
CodePudding user response:
At the template_name variable you have filter replace a dot with an interval and after that handle filter.
After that interaction the page.chisiamo no longer be like the template string.
You transform it at first to page chisiamo with the replace, after to page-chisiamo with handle filter.
You can use this:
{%- if template_name == 'page-chisiamo' -%}
{%- assign overlay_header = true -%}
{%-endif -%}
Or you can just check if the template_name contains the chisiamo, like this:
{%- if template_name contains 'chisiamo' -%}
{%- assign overlay_header = true -%}
{%-endif -%}