SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    some help with template layout

    Hello,

    I got my main layout in views/layouts/application.rhtml Now what I
    would like to do is wrap some code around everything in my
    messages controller. (all actions)

    How should I accomplish something like that? It is some navigation only related to that controller.


    Best regards.
    Asbjørn Morell.

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This line:
    Code:
    layout 'application'
    In a controller will force actions in that controller to use your application layout rather than their default layout

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still want to use my my application.rhtml layout as it holds header, body and footer. I guess I can call a partial from each message view :/

  4. #4
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As long as the application.rhtml contains:
    Code:
    <%= @content_for_layout %>
    or
    Code:
    <%= yield  %>
    At the point where you want your view to be included within the layout, that is just what you will achieve.

    That is, Rails automatically displays each view within the layout for the current controller. That layout will contain one of the two bits of code, and it is at that point within the layout, that the view code will be inserted.

    Specifying layout 'application' forces the view for the controller to use the layout application.rhtml rather than /layout/controller_name.rhtml


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •