# Multiple @content\_for\_layout in template?

**URL:** <https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214>\
**Category:** Rails\
**Created:** [July 27, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214 "2006-07-27T20:59:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 27, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214/1 "2006-07-27T20:59:07Z")

</div>

Hi guys,

I’m having a few experiments making sites with Rails and I’ve come  
across a problem. I’ve made a template for the parts of the site that  
the public will see and it has two main columns in it, a main content  
column and a thin side column. The content in each of these will change  
on each page of the site but I’m not exactly sure about how to send  
different data to each column.

At the moment the main column is being filled with data from a view file  
using \<%= @content\_for\_layout %\>. How would I go about getting another  
set of data from another view file into the other column?

Thanks  
Henry

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 31, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214/2 "2006-07-31T20:39:05Z")

</div>

Can anyone help out here? Please!

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 31, 2006, 9:05pm UTC](https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214/3 "2006-07-31T21:05:37Z")

</div>

On Jul 31, 2006, at 2:39 PM, Henry B. wrote:  
[previous post:

Hi guys,

I’m having a few experiments making sites with Rails and I’ve come  
across a problem. I’ve made a template for the parts of the site that  
the public will see and it has two main columns in it, a main content  
column and a thin side column. The content in each of these will change  
on each page of the site but I’m not exactly sure about how to send  
different data to each column.

At the moment the main column is being filled with data from a view file  
using \<%= @content\_for\_layout %\>. How would I go about getting another  
set of data from another view file into the other column?

Thanks  
Henry

]

> Can anyone help out here? Please!

You can use instance variables in a layout as well, just set it in  
the controller (@title for example) then reference it.

You may also want to check out the content\_for function (http://  
[api.rubyonrails.org/classes/ActionView/Helpers/](http://api.rubyonrails.org/classes/ActionView/Helpers/)  
CaptureHelper.html#M000528)

Finally, all of this is deprecated. Use ‘yield’ or ‘yield :name’ in  
place of ‘@content\_for\_layout’ and ‘content\_for’, respectively.

Here are some details: [http://weblog.rubyonrails.org/2006/4/25/use-](http://weblog.rubyonrails.org/2006/4/25/use-)  
params-not-params

-Mat

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 31, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/multiple-content-for-layout-in-template/100214/4 "2006-07-31T21:20:26Z")

</div>

Legendary. Thanks very much! 😃
