Forum: Radiant CMS Can you use controllers/views within a tag

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
jsmorris (Guest)
on 2007-02-04 19:46
(Received via mailing list)
Using radiant (mental), I have created my extension and have the
model/view/controller working from within the admin page layout with
no problems.  I can create/list/edit/destroy my model instances.

Now, I want to list each instance of my model from within a page on
the website using a radius tag <r:mytag /> and the website layout.  I
believe using a tag would be the most appropriate.

As I have tried so far, I have recreated the view from within my tag
using the content << "<table>...</table>" method.  It seems that there
should be a better way so that I don't repeat myself by creating two
views, one for the admin page and the second for the radius tag.

Is there a way to reuse the view/controller inside the radius tag?
Maybe something like

module MyTag
  include Radiant::Taggable

  desc %{  <r:mytag />

  Displays the list of mytag available. }
  tag "mytag" do |tag|
    render(:controller => MyController, :action => MyAction)

or something to that effect.

I would also like to render the form so that users can input models on
my site as well.  I just thought that I would try the list first.

Very new to all of this, so any pointers or directions would be much

Jacob B. (Guest)
on 2007-02-05 04:10
Jason, can you clarify what you are trying to do a little more?  You
seem to be asking multiple questions at once.
jsmorris (Guest)
on 2007-02-05 04:35
(Received via mailing list)
My question is...

Can a typical rails view (created under the extension in the
extension/app/view folder) be render from a radius tag?
Sean C. (Guest)
on 2007-02-05 07:02
(Received via mailing list)
Short answer: no.  Long answer: maybe, but it could get ugly.  Although
maybe what you're trying to do doesn't really need a traditional Rails
view template, but a collection of tags and a snippet?  Let us know more
of what you want to do.

Michael J. (Guest)
on 2007-02-05 07:08
(Received via mailing list)
>   Displays the list of mytag available. }
>   tag "mytag" do |tag|
>     render(:controller => MyController, :action => MyAction)
>   end

I wish it was this easy.

I look forward to the discussion of how best to do this sort of thing...
Daniel S. (Guest)
on 2007-02-05 09:02
(Received via mailing list)
> >   Displays the list of mytag available. }
> >   tag "mytag" do |tag|
> >     render(:controller => MyController, :action => MyAction)
> >   end
> I wish it was this easy.

This is just off the top of my head but:

class EasyControllerExtension

 def activate
  class << SiteController
    def show_uncached_page(url)
      @page = find_page(url)
      unless @page.nil?
        @cache.cache_response(url, response) if live? and @page.cache?
        @performed_render = true
        render :template => 'site/not_found', :status => 404
    rescue Page::MissingRootPageError
      redirect_to welcome_url
  class << Page
    attr_accessor :controller
    def process_controller(controller)
      @controller = controller
      process(controller.request, controller.response)

Then you should be able to just do:

tag "mytag" do |tag| => 'monkeys')

jsmorris (Guest)
on 2007-02-06 08:38
(Received via mailing list)
I tried to implement your suggestion here, but I was not successful.
I am not sure I follow what this code is doing...but I am still
learning ruby.

I attached my attempt.  Maybe you or some else can see what is wrong.

This was the error I was getting

`load_missing_constant': uninitialized constant ApplicationController
         ... 29 levels...
        from /usr/local/bin/mongrel_rails:18:in `load'
        from /usr/local/bin/mongrel_rails:18

Michael J. (Guest)
on 2007-09-26 01:06
(Received via mailing list)
Jason, did you ever get this to work?
jsmorris (Guest)
on 2007-09-26 01:08
(Received via mailing list)
Unfortunately, I have pulled away from doing any more work on this,
but I hope to get back to this soon.
Daniel S. (Guest)
on 2007-09-26 01:09
(Received via mailing list)
Oh, you need to explicitely require 'application' to load the
application controller - The application controller is not loaded until
after the extensions, which means that any reference to a controller
will be unable to load it's superclass (as the class is named
ApplicationController, but it is loaded from an application.rb file - a
default I've never understood about rails, but I'm guessing it served a
historical purpose).
This topic is locked and can not be replied to.