D''Andrew \"Dave\" Thompson
2005-Dec-28 22:36 UTC
[Templates] [Noob] templates across controllers?
Fine Rails Hackers: I am trying to decide how to approach a templating concern. I would like to define a standard template for all of my pages (including a basic header, styles, footer) across my five base controllers: desktop, events, financials, and records, account. Is there a top level place to declare a template across the entire application regardless of the controller? I understand how to declare a template within a controller, say desktop (in app/views/layouts/desktop.rhtml). But how do I define something that can serve as a template for all of the controllers? I don''t want to reproduce the template for each controller (in the layout folder). Thank you, Dave -- ~~~~~~~~~~~~~~~~~~~ D''Andrew "Dave" Thompson http://dathompson.blogspot.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Dave, Try a app/views/layout/application.rhtml Chris Nolan.ca http://kekova.ca/ On Dec 28, 2005, at 17:36, D''Andrew Dave Thompson wrote:> Fine Rails Hackers: > > I am trying to decide how to approach a templating concern. > > I would like to define a standard template for all of my pages > (including a basic header, styles, footer) across my five base > controllers: desktop, events, financials, and records, account. > > Is there a top level place to declare a template across the entire > application regardless of the controller? > > I understand how to declare a template within a controller, say > desktop (in app/views/layouts/desktop.rhtml). But how do I define > something that can serve as a template for all of the controllers? > I don''t want to reproduce the template for each controller (in the > layout folder). > > Thank you, > > Dave > -- > ~~~~~~~~~~~~~~~~~~~ > D''Andrew "Dave" Thompson > http://dathompson.blogspot.com_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
i think the best way to do this would be to have all your pages use the same layout, and include the style-sheet, header and footer info in there. This should be easy to do, if u have a layout called application (and no other layout files) your app will use this across all pages. Alternatively you can declare the layout using the layout method (see rails api for more information on that). On 29/12/05, D''Andrew Dave Thompson <dandrew.thompson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Fine Rails Hackers: > > I am trying to decide how to approach a templating concern. > > I would like to define a standard template for all of my pages (including a > basic header, styles, footer) across my five base controllers: desktop, > events, financials, and records, account. > > Is there a top level place to declare a template across the entire > application regardless of the controller? > > I understand how to declare a template within a controller, say desktop (in > app/views/layouts/desktop.rhtml). But how do I define > something that can serve as a template for all of the controllers? I don''t > want to reproduce the template for each controller (in the layout folder). > > Thank you, > > Dave > -- > ~~~~~~~~~~~~~~~~~~~ > D''Andrew "Dave" Thompson > http://dathompson.blogspot.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
D''Andrew \"Dave\" Thompson
2005-Dec-29 00:39 UTC
Re: [Templates] [Noob] templates across controllers?
Worked like a charm. I just found in the book where it notes the use of "application" for applying layouts to all controllers. Of note, I had to remove the other controller-named layouts in the same folder, which is the first place Rails goes. Thanks. On 12/28/05, Chris Lowder <clowder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > i think the best way to do this would be to have all your pages use > the same layout, and include the style-sheet, header and footer info > in there. > > This should be easy to do, if u have a layout called application (and > no other layout files) your app will use this across all pages. > Alternatively you can declare the layout using the layout method (see > rails api for more information on that). > > On 29/12/05, D''Andrew Dave Thompson <dandrew.thompson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Fine Rails Hackers: > > > > I am trying to decide how to approach a templating concern. > > > > I would like to define a standard template for all of my pages > (including a > > basic header, styles, footer) across my five base controllers: desktop, > > events, financials, and records, account. > > > > Is there a top level place to declare a template across the entire > > application regardless of the controller? > > > > I understand how to declare a template within a controller, say desktop > (in > > app/views/layouts/desktop.rhtml). But how do I define > > something that can serve as a template for all of the controllers? I > don''t > > want to reproduce the template for each controller (in the layout > folder). > > > > Thank you, > > > > Dave > > -- > > ~~~~~~~~~~~~~~~~~~~ > > D''Andrew "Dave" Thompson > > http://dathompson.blogspot.com > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- ~~~~~~~~~~~~~~~~~~~ D''Andrew "Dave" Thompson http://dathompson.blogspot.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails