# Incorporating Radiant and site functionality

**URL:** <https://www.ruby-forum.com/t/incorporating-radiant-and-site-functionality/99624>\
**Category:** Radiant CMS\
**Created:** [July 24, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/incorporating-radiant-and-site-functionality/99624 "2006-07-24T16:00:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@matthew\_d](https://www.ruby-forum.com/u/matthew_d)\
**Post date:** [July 24, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/incorporating-radiant-and-site-functionality/99624/1 "2006-07-24T16:00:38Z")

</div>

Hi,

Just a question about whether I’m doing this correctly as I’m a new  
Radiant user.

I have a client (as in person, not software!) who wants to use a Rails  
CMS (I’ve recommended Radiant) but wants to build a site around it  
that has extra functionality (filling in forms and having structured  
data saved). The UI for this extra functionality needs to be managed  
under the CMS so I’ve done a bit of a test and, by using a Rails  
Engine, I can add the controller and model as an engine. In my engine  
controller I then have:

class MyController \< ApplicationController  
def new  
render\_view(:new, Thing.new)  
end  
def save  
render\_view(:save, Thing.create!(params[:thing]))  
end  
def view  
render\_view(:view, Thing.find(params[:id]))  
end  
def render\_view(view, thing)  
render\_component :controller =\> ‘site’, :action =\> ‘show\_page’,  
:params =\> { :url =\> “/my\_controller\_views/#{ view }”, :thing =\> thing  
}  
end  
end

Essentially delegating the rendering of the page by using components  
because I cannot render a normal Rails RHTML page.

In my config/routes.rb I ensure that MyController is configured  
_before_ the default site controller:

# MyController handling

map.with\_options(:controller =\> ‘my’) do |my\_controller|  
my\_controller.my\_controller\_new ‘my\_controller/new’,  
:action =\> ‘new’  
my\_controller.my\_controller\_save ‘my\_controller/save’,  
:action =\> ‘save’  
my\_controller.my\_controller\_view ‘my\_controller/view/:id’,  
:action =\> ‘view’  
end

# Site URLs

… rest of normal routes.rb

This all seems to work wonderfully as I’ve added some Radius tags  
(directly into PageContext for the moment!) for accessing the ‘thing’.

But I do have a serious question on top of this: I assume that the  
“preferred” method for adding these tags is to build a behaviour?  
What happens when you want to have a standard set of tags available  
(for example, I have a click-through link engine too that counts  
clicks through to URLs) and you want these to be available to all  
pages; I can’t have two behaviours for each page (the click-through  
links _and_ the ‘thing’ tags), nor can I easily extend the PageContext  
class.

Matt

---

<div class="post-metadata">

**Author:** ![matthew\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@matthew\_d](https://www.ruby-forum.com/u/matthew_d)\
**Post date:** [July 24, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/incorporating-radiant-and-site-functionality/99624/2 "2006-07-24T16:55:44Z")

</div>

Matthew D. wrote:

> What happens when you want to have a standard set of tags available  
> (for example, I have a click-through link engine too that counts  
> clicks through to URLs) and you want these to be available to all  
> pages…

To add global tags call the define\_tags method directly on  
Behavior::Base like this:

Behavior::Base.define\_tags do  
tag “hello” do  
“Hello World!”  
end  
#…  
end

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