Show different content in header based on page | Community
Skip to main content

Show different content in header based on page

  • September 14, 2018
  • 4 replies
  • 0 views

I am editing the header handlebars file in the theme and am trying to display a search bar on the header for all pages except the homepage. How can I conditionally show html content based on the page a user is on?

This topic has been closed for replies.

4 replies

  • September 17, 2018

Hi Chris,

You can't natively in Zendesk Guide, so you would have to create a javascript that shows/hides based on URL. Unfortunately i am not a programmer, so I can't guide you on how to do that...


Trapta
  • September 26, 2018

Hi @Chris,

You can refer to this post to create something like this. Let me know if this solves the issue.

Team Diziana


  • March 8, 2019

Hello Carsten,

The code itself is simple - here is mine to not display the Footer on the new_request page since it is the contact us page:

<script>
var currentLocation = window.location.pathname;
if (currentLocation != "/hc/en-us/requests/new") {

<footer CSS code>

}
</script>

The problem is the Copenhagen them CSS code doesn't play well with the JS code, and i can't seem to get the script to run correctly inside the CSS code(works fine outside). I cut a ticket to Support and if they have a solution I will post it here.

John

 


  • July 22, 2019

Hello,

It would be awesome if you could add this to conditionals/helpers.

I was trying to do exactly the same thing as OP, in header.hbs:

{{#unless current_page 'home'}} 
{{search submit=false instant = true}}
{{/unless}}

Thanks!