Hide navigation bar and footer on specific pages

I am creating a website for my new company and want to create a landing page for my product that does not have a navigation bar or footer. I want the landing page to be simple and just focus on the product.

I am coding for Ruby on Rails. Twitter Bootstrap is what I use to style the navigation bar and footer.

My home page and page have a navigation bar and footer, but I don’t want the navigation page and footer on my product’s landing page.

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

+5
source share
4 answers

To add code.prio to the answer, you can simply use the conditional operator in the application layout (it retains the problem of supporting two layouts):

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

Not as good as another answer, but works better. If you have more than one layout, it becomes uncomfortable for them to support both.

+8
source

Yes you can do it. One easy way is to use a different layout file for the landing page controller, different from the standard application.html.erb . On the page of the desired template, write your own layout name, which will contain various specifications. Let me give you an example

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

This will load another layout with a different look as you want for your site, while the default layout may contain a basic navigation bar and products for other pages.

Thanks. Hope this way helps solve your problem.

Visit this link for more information. ActionView API Docs

+7
source

It is very simple:

  # application.html.erb <% unless action_name == "index" %> # render the footer partial "_footer.html.erb" file from "shared" folder <%= render 'shared/footer' %> <% end %> 
+3
source

I had the same problem and solved it like this:

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

using action_name instead of controller_name .

-1
source

Source: https://habr.com/ru/post/1239216/


All Articles