HelpCenter - only show element on homepage | Community
Skip to main content

HelpCenter - only show element on homepage

  • October 5, 2021
  • 1 reply
  • 0 views

Hi,

we have 2 different color variations of our logo and on the home page of the helpcenter we'd like to show logo 1 and on all other pages logo 2.
Can anybody please provide an if / else statement? I couldn't figure out how to do it.

1 reply

Tipene
  • October 6, 2021

Hi Marc,

Thanks for reaching out!

One way you could go about this is by creating a second logo div in the header.hbs file and conditionally rendering it in the script.js file with a bit of CSS. Here's an example for you to take a look at:

HTML + curlybars

<div class="home_logo">
{{#link 'help_center'}}
<img src={your_logo_here} alt="{{t 'home_page' name=help_center.name}}" />
{{#if settings.show_brand_name}}
<span aria-hidden="true">{{help_center.name}}</span>
{{/if}}
{{/link}}
</div>

<div class="logo">
{{#link 'help_center'}}
<img src={{settings.logo}} alt="{{t 'home_page' name=help_center.name}}" />
{{#if settings.show_brand_name}}
<span aria-hidden="true">{{help_center.name}}</span>
{{/if}}
{{/link}}
</div>

CSS:

.home_logo {
display: none;
}

JS:

const home_logo = document.querySelector(".home_logo")
const logo = document.querySelector(".logo")

if(window.location.href == "https://{{subdomain}}.zendesk.com/hc/en-us"){
logo.style.display = "none";
home_logo.style.display = "block";
};

Here's an article where you can read a bit more about customizing your help center.

https://support.zendesk.com/hc/en-us/articles/203664326-Customizing-your-help-center-theme

I hope this helps! Feel free to reach out with any questions.

Tipene