Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide nav bar and footer on certain pages

I'm building a website for my new company and want to create a landing page for my product that doesn't have a nav bar or a footer. I want to keep the landing page simple and just focus on the product.

I'm coding in Ruby on Rails. Twitter Bootstrap is what I'm using for styling the nav bar and footer.

My home page and about page have a nav bar and footer, but I don't want my product landing page to have the nav bar and footer.

Any suggestions on how I can hide the nav bar and footer on my landing page, but keep it on my other pages?

like image 404
Seth Allen Avatar asked Dec 25 '15 18:12

Seth Allen


2 Answers

To add to code.prio's answer, you could just use a conditional statement in your application layout (saves the hassle of maintaining two layouts):

#app/views/layouts/application.html.erb
<% unless controller_name == "landing" %>
   ... navbar ...
<% end %>

Not as pretty as the other answer, but works better. If you have more than one layout, it gets annoying having to maintain them both.

like image 153
Richard Peck Avatar answered Sep 20 '22 15:09

Richard Peck


Yes , you can do it . One easy way is to use a different layout file for the landing page controller other than the default application.html.erb . In your desired template page write a custom layout name which will hold up the different kinds of specification . Let me give an example ,

class SiteController < ApplicationController
  layout "landing_page"
  ...
end

This will load up a different layout with different view as you want for your site , while the default layout can hold the basic navbar and products for other pages.

Thanks . Hope this one way will solve your problem .

Visit This link for more information . ActionView API Docs

like image 41
Mahabub Islam Prio Avatar answered Sep 20 '22 15:09

Mahabub Islam Prio