# Best Practices for multiple Layouts that have slight variati

**URL:** <https://www.ruby-forum.com/t/best-practices-for-multiple-layouts-that-have-slight-variati/82961>\
**Category:** Radiant CMS\
**Created:** [January 22, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/best-practices-for-multiple-layouts-that-have-slight-variati/82961 "2007-01-22T18:45:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [January 22, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/best-practices-for-multiple-layouts-that-have-slight-variati/82961/1 "2007-01-22T18:45:07Z")

</div>

Hello-

I was wondering if there were some tips on the ‘best’ way to approach  
this problem.

I have a site each of the 5 top level pages have the same format but a  
different:

- top image
- color scheme
- tag line

I was thinking I would:

- create Snippets for the common elements
- create Layouts for the 5 types and include the common Snippets

This is not ideal because there is still alot of repition in the  
layouts, it’s not very DRY.

Ideal I would create a 5 data structures that encapsulate the  
differences and have 1 Layout that pulls in the correct data to create  
the required unique Layout.

Is there someway to accomplish this? Or is there a better approach?

Thanks-  
Michael

---

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [January 24, 2007, 11:49pm UTC](https://www.ruby-forum.com/t/best-practices-for-multiple-layouts-that-have-slight-variati/82961/2 "2007-01-24T23:49:59Z")

</div>

On Jan 22, 2007, at 12:44 PM, Michael J. wrote:

> Ideal I would create a 5 data structures that encapsulate the  
> differences and have 1 Layout that pulls in the correct data to create  
> the required unique Layout.
> 
> Is there someway to accomplish this? Or is there a better approach?

This is actually the way to do it. In your layout user \<r:content  
part="{top,style,tag}" inherit=“true”\>, and place the required  
changes in the correctly named parts on the top pages. The  
inherit=“true” will make the children pages search up to those top  
pages to find the parts.

~~ Brian

---

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [January 24, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/best-practices-for-multiple-layouts-that-have-slight-variati/82961/3 "2007-01-24T16:49:27Z")

</div>

Michael,

Try \<r:if\_url matches="/your\_location/"\>

You could create rules based upon the url to change the content  
within one layout.

If, however, you wanted to edit the layout based upon an individual  
page and not based upon the URL, then your solution is probably the  
most flexible.  
I’m no expert though, so possibly someone else will chime in.

-Jim
