Show different content in header based on page
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?
-
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...
-
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
-
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!
Publicação fechada para comentários.
4 Comentários