# Re: Utilizing multiple behaviors per page

**URL:** <https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657>\
**Category:** Radiant CMS\
**Created:** [September 5, 2006, 11:12pm UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657 "2006-09-05T23:12:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 5, 2006, 11:12pm UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/1 "2006-09-05T23:12:37Z")

</div>

I just recently discovered Radiant and have utilized it on a personal  
project, and one of the pieces I was missing was a comments section -  
which I was glad to find via the list. However - do have a question.  
I’m also using the gallery behavior in one section - is there anyway  
to combine 2 behaviors on sets of pages, i.e. comments and gallery -  
or is this just a limitation of the behaviors?

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 6, 2006, 12:14am UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/2 "2006-09-06T00:14:43Z")

</div>

I believe you could have a child page that has the comments behavior and  
display that page in the parent using the children tag. The ability to  
have  
multiple child pages each with thier own behavior, and subsequently  
display  
them all on the parent page is a general technique that gets used quite  
a  
bit in Radiant (and makes it super flexible too 😛 )

Justin

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 6, 2006, 5:19am UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/3 "2006-09-06T05:19:09Z")

</div>

On Sep 6, 2006, at 7:12 AM, Justin Marney wrote:

> The ability to have multiple child pages each with thier own  
> behavior, and subsequently display them all on the parent page is a  
> general technique that gets used quite a bit in Radiant

This gives me the idea of creating something on the wiki about  
“Radiant Recipes” or something, documenting common usage patterns,  
tips, and radiant idioms. What do people think?

Bodhi

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 6, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/4 "2006-09-06T14:33:52Z")

</div>

Bodhi wrote:

> On Sep 6, 2006, at 7:12 AM, Justin Marney wrote:
> 
> > The ability to have multiple child pages each with thier own  
> > behavior, and subsequently display them all on the parent page is a  
> > general technique that gets used quite a bit in Radiant
> 
> This gives me the idea of creating something on the wiki about  
> “Radiant Recipes” or something, documenting common usage patterns,  
> tips, and radiant idioms. What do people think?

Perhaps the How To section would work for this?

[http://dev.radiantcms.org/radiant/wiki/HowTos](http://dev.radiantcms.org/radiant/wiki/HowTos)

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 7, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/5 "2006-09-07T19:25:37Z")

</div>

Is there a reason why this doesn’t work the other way around, for  
example:  
I have an area of the website which I have restricted access to, I  
wanted to  
have a parent page that takes care of the restrictions for all child  
pages.  
What I did was have a parent with a restricted\_behavior and a body part  
that  
shows either a ‘registered’ or a ‘not\_registered’ page parts depending  
if  
the user is registered or not.  
Then I have child pages hat do not have a body page part, so radiant  
finds  
the body page part in the parent, but if the tags I used in the parent  
are  
not in the child behavior I get errors that the tags are not recognized,  
which made me duplicate the tags to all behaviors I use with the page  
children.  
Is this the way it suppose to work? Is there any other way of doing what  
I  
want to do?  
Dror

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 6, 2006, 11:02am UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/6 "2006-09-06T11:02:50Z")

</div>

Bodhi wrote:

> This gives me the idea of creating something on the wiki about  
> “Radiant Recipes” or something, documenting common usage patterns,  
> tips, and radiant idioms. What do people think?
> 
> Bodhi

I think this is an excellent idea. I’m fairly new to Radiant as well and  
have been struggling with some of the fundamentals such as the multiple  
behaviours type setup you mentioned. A single place that covers a lot of  
these pitfalls without having to search through a forum would make entry  
to Radiant a lot easier.

Kev

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 7, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/7 "2006-09-07T19:43:39Z")

</div>

dror tirosh wrote:

> not in the child behavior I get errors that the tags are not recognized,  
> which made me duplicate the tags to all behaviors I use with the page  
> children.  
> Is this the way it suppose to work? Is there any other way of doing what I  
> want to do?  
> Dror

A clever hack for using multiple behaviors on the same page is to create  
another page, assign a behavior to it, and then use the \<r:find /\> tag  
to include content from it. For example, on the Ruby-Lang site we have a  
top-projects box which is repeated on most of the top level pages. To  
make this work we do this:

\<r:find url=“/en/libraries/top-projects/”\>  
\<r:content part=“top-projects” /\>  
\</r:find\>

This outputs the “top-projects” part of the top projects page. You can  
see it in action in several places:

[http://new.ruby-lang.org/en/](http://new.ruby-lang.org/en/)  
[http://new.ruby-lang.org/en/libraries/](http://new.ruby-lang.org/en/libraries/)  
[http://new.ruby-lang.org/en/libraries/top-projects/](http://new.ruby-lang.org/en/libraries/top-projects/)

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 8, 2006, 1:16am UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/8 "2006-09-08T01:16:23Z")

</div>

I know, I use the same solution for the events and promotions on our  
sites  
(look at the right sidebar on [lokihostel.com](http://lokihostel.com)).  
But I was looking for a solution I can offer to other users who enter  
data  
in our CMS.  
That is why I thought I could use the fact that Radiant searches up for  
body  
parts, to have a body part that have all that extra tagging, and my  
users  
just take care of the text in the other page parts.  
Most of my users will simply wont enter data when it has tags in it,  
that is  
why most of the content entered by users on our site is through the  
fckeditor a wysiwyg editor.  
So I was looking for a different solution.  
If there is none I would accept that as well, but if you guys have a  
different hack I’ll be happy.

BTW - I don’t see why the two acts so differently, so if I look for a  
page  
it uses its own behavior but if radiant looks for a page (like a body  
part)  
it uses the current page behavior.

Dror

---

<div class="post-metadata">

**Author:** ![J\_Coppedge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@J\_Coppedge](https://www.ruby-forum.com/u/J_Coppedge)\
**Post date:** [September 8, 2006, 1:52am UTC](https://www.ruby-forum.com/t/re-utilizing-multiple-behaviors-per-page/67657/9 "2006-09-08T01:52:27Z")

</div>

dror tirosh wrote:

> So I was looking for a different solution.  
> If there is none I would accept that as well, but if you guys have a  
> different hack I’ll be happy.

For this kind of thing I’d recommend making the tags global (so they can  
be used on any page). There seems to be a common misconception that  
behaviors are the appropriate way to add tags to a page. You can use  
behaviors for this, but most of the time it is only useful if you tie it  
in with other features (like overriding the render\_page method).

> BTW - I don’t see why the two acts so differently, so if I look for a page  
> it uses its own behavior but if radiant looks for a page (like a body part)  
> it uses the current page behavior.

It’s so that you can cycle through the children of a page and render  
parts in the correct context.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
