Question

Maybe this is a simple question but I am working on a project written in Ruby and HAML where the company wants Olark chat on every page of their website except the homepage. The only feasible way to do this is to insert the content into footer.html.haml.

I've looked around and I can't seem to figure out how to do this. How would I go about adding content to every page except the homepage?

Was it helpful?

Solution

Wrap your olark code in an unless statement where you show the Olark on every page unless the current_page is your homepage, or root_path.

<% unless current_page?(root_path) %>
  Olark code
<% end %>

OTHER TIPS

Create a different layout that is only used on the homepage

You could give the homepage it's own body class <body class="homepage"> and then set the display of the chat container to none .homepage #chat {display:none;}

You can add a condition to hide the code of Olark. To do this, you can check the URL of the current page, and if the URL matches the address of your homepage, don't execute the Olark's code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top