Incorporating Radiant and site functionality

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs