Hi guys.
- I have a nav.html which is included in my base.html
- I want nav.html to get
extra.banner from the current page
problem:
nav.html and base.html don’t have access to page
the end goal:
I want the layout and style of my nav.html to change based on if the current page has a banner set or not.
if page then if page.extra.banner?
1 Like
this doesn’t fix the actual problem. Maybe I explained it badly.
I want to know the value of banner from the current page I’m on, from within nav.html because I want to change the style of my navigation bar for the pages that have a banner.
The problem is I can’t even check if a page has a banner or not. because nav.html doesn’t have access to the page variable.
Oh God nevermind!
This actually fixes the issue. I understand now the error was because the home page. doesn’t have page variable. so I have to first check if the page variable even exists.
the current working code in nav.html
{% if page.extra.banner or current_path == "/" %}
{% set header_class = "header--banner" %}
{% else %}
{% set header_class = "header" %}
{% endif %}
<header class={{header_class}}>
Thank you so much for the tip. my brain was fried.