AbsolutZero
2007-Apr-01 21:08 UTC
Newbie... Layouts and how to create universal header throughout site...
I have a simple question that I''m sure will be painful to answer for some of you experts, but I thank you for bearing with me... I want a simple 5-page website. I have a custom header consisting of a simple banner and horizontal navbar underneath it. I''d like this to stay the same through every page. Now some of my pages are interactive with the user like shopping carts etc, but some are static, like a current news section. I made a controller for each page, so that each page would get a View associated with it. The way I have my pages written now, is that the code for the banner and navbar appear on the top of each individual page.rhtml in the /views/layouts section, and then each page has its individual content on its respective index.html. The main problem I see, is that if that header changes, I have to go into each individual layout and change it, and I know thats definitely not the way to do it, but I can''t figure out how to render that code at the top of each layout... Any help is greatly appreciated. Thanks. -Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Apr-01 22:57 UTC
Re: Newbie... Layouts and how to create universal header throughout site...
Hey AbsoluteZero, you can do the following: a) create a partial for your header (e.g. app/views/shared/_header.rhtml ) b) create a partial for your nav bar (e.g. app/views/shared/_nav_bar.rhtml ) c) create a partial for your footer (e.g. app/views/shared/_footer.rhtml ) d) setup your layout app/views/layouts/application.rhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Untitled Document</title> <%= javascript_include_tag :defaults %> </head> <body> <%= render :partial => ''shared/header'' %> <%= render :partial => ''shared/nav_bar'' %> <%= yield :layout %> <%= render :partial => ''shared/footer'' %> </body> </html> Good luck, -Conrad On 4/1/07, AbsolutZero <absolut0music-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a simple question that I''m sure will be painful to answer for > some of you experts, but I thank you for bearing with me... > > I want a simple 5-page website. I have a custom header consisting of a > simple banner and horizontal navbar underneath it. I''d like this to > stay the same through every page. Now some of my pages are interactive > with the user like shopping carts etc, but some are static, like a > current news section. I made a controller for each page, so that each > page would get a View associated with it. The way I have my pages > written now, is that the code for the banner and navbar appear on the > top of each individual page.rhtml in the /views/layouts section, and > then each page has its individual content on its respective > index.html. > > The main problem I see, is that if that header changes, I have to go > into each individual layout and change it, and I know thats definitely > not the way to do it, but I can''t figure out how to render that code > at the top of each layout... > > Any help is greatly appreciated. > > Thanks. > > -Dan > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
AbsolutZero
2007-Apr-03 20:54 UTC
Re: Newbie... Layouts and how to create universal header throughout site...
Thank you so much, thats exactly what I was looking for! On Apr 1, 6:57 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey AbsoluteZero, you can do the following: > > a) create a partial for your header (e.g. app/views/shared/_header.rhtml ) > b) create a partial for your nav bar (e.g. app/views/shared/_nav_bar.rhtml ) > c) create a partial for your footer (e.g. app/views/shared/_footer.rhtml ) > d) setup your layout app/views/layouts/application.rhtml > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> > <title>Untitled Document</title> > <%= javascript_include_tag :defaults %> > </head> > > <body> > > <%= render :partial => ''shared/header'' %> > <%= render :partial => ''shared/nav_bar'' %> > > <%= yield :layout %> > > <%= render :partial => ''shared/footer'' %> > > </body> > </html> > > Good luck, > > -Conrad > > On 4/1/07, AbsolutZero <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I have a simple question that I''m sure will be painful to answer for > > some of you experts, but I thank you for bearing with me... > > > I want a simple 5-page website. I have a custom header consisting of a > > simple banner and horizontal navbar underneath it. I''d like this to > > stay the same through every page. Now some of my pages are interactive > > with the user like shopping carts etc, but some are static, like a > > current news section. I made a controller for each page, so that each > > page would get a View associated with it. The way I have my pages > > written now, is that the code for the banner and navbar appear on the > > top of each individual page.rhtml in the /views/layouts section, and > > then each page has its individual content on its respective > > index.html. > > > The main problem I see, is that if that header changes, I have to go > > into each individual layout and change it, and I know thats definitely > > not the way to do it, but I can''t figure out how to render that code > > at the top of each layout... > > > Any help is greatly appreciated. > > > Thanks. > > > -Dan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
reed
2007-Apr-03 21:09 UTC
Re: Newbie... Layouts and how to create universal header throughout site...
For a quick screencast tutorial on how layouts are selected see the "All About Layouts" at http://www.railscasts.com/ On Apr 4, 8:54 am, "AbsolutZero" <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you so much, thats exactly what I was looking for! > > On Apr 1, 6:57 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey AbsoluteZero, you can do the following: > > > a) create a partial for your header (e.g. app/views/shared/_header.rhtml ) > > b) create a partial for your nav bar (e.g. app/views/shared/_nav_bar.rhtml ) > > c) create a partial for your footer (e.g. app/views/shared/_footer.rhtml ) > > d) setup your layout app/views/layouts/application.rhtml > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> > > <title>Untitled Document</title> > > <%= javascript_include_tag :defaults %> > > </head> > > > <body> > > > <%= render :partial => ''shared/header'' %> > > <%= render :partial => ''shared/nav_bar'' %> > > > <%= yield :layout %> > > > <%= render :partial => ''shared/footer'' %> > > > </body> > > </html> > > > Good luck, > > > -Conrad > > > On 4/1/07, AbsolutZero <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have a simple question that I''m sure will be painful to answer for > > > some of you experts, but I thank you for bearing with me... > > > > I want a simple 5-page website. I have a custom header consisting of a > > > simple banner and horizontal navbar underneath it. I''d like this to > > > stay the same through every page. Now some of my pages are interactive > > > with the user like shopping carts etc, but some are static, like a > > > current news section. I made a controller for each page, so that each > > > page would get a View associated with it. The way I have my pages > > > written now, is that the code for the banner and navbar appear on the > > > top of each individual page.rhtml in the /views/layouts section, and > > > then each page has its individual content on its respective > > > index.html. > > > > The main problem I see, is that if that header changes, I have to go > > > into each individual layout and change it, and I know thats definitely > > > not the way to do it, but I can''t figure out how to render that code > > > at the top of each layout... > > > > Any help is greatly appreciated. > > > > Thanks. > > > > -Dan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---