We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

If else/if display partial for hero area on specific pages (not all pages).

Amber Leigh Turner February 20, 2015 by Amber Leigh Turner

Hello!

I'm new to Statamic (well, been using it on and off for two years, but my experience is like a newbie). I've been struggling to get this to work for a few days now.

Basically, I have a <header> tag that has a <div class="hero"> inside of it. I've created three partial files: header-home.html, header.html and header-hero.html. Home.html is the same as hero.html but with two extra lines of code. Header.html is the one that DOESN'T have .hero.

I'm wanting the header.html to be the default on ALL pages. However, I want the header-home.html to be on the home page (segment_1) and header-hero.html to be on specific pages (slugs): "home", "projects", "hire".

Below is the code I've been working with. Obviously it doesn't work, which is why I need help.


{{ if ! segment_1 == true }}
          
          {{ theme:partial src="header-home" }}


{{ elseif segment_1 == "projects" or "insights" or "hire" }}
          
          {{ theme:partial src="header-hero" }}


{{ else }}
          
          {{ theme:partial src="header" }}
{{ endif }}

Basically what this code is doing is putting the header-home on the home page, and header-hero on ALL other pages (not just those specific pages). I know this because I have the debug panel set to true and that is what it is saying.

Can someone help me figure out what I've messed up? You will save me a few gray hairs.

(The site isn't currently live. I'm running it on MAMP Pro).

Thank you in advance!

Answered by Amber Leigh Turner!
>>>>>>> Answered <<<<<<<
7 Replies
5 Followers