Category Archives: Radiant

Radiant CMS & Web Services

As I’ve written about previously, I’m working on a Radiant site with my buddy KB. We want to leverage a newsletter building application and an email sending service that we’ve developed for our other projects in this site. To do so, we needed to consume some web services that are part of another Rails application to do the subscribing and unsubscribing from a mailing list. There doesn’t seem to be much information about consuming web services from a Radiant application, so I thought I’d share what I found here. My discovery was based on a suggestion by Sean Cribbs to look at the Radiant LDAP extension.

So basically I found that you need to create a global tags module. In it you define your ActionWebService API and the tags you’ll use. Here’s a sample:


require 'action_web_service'

module MyTest
   include Radiant::Taggable
   class MyTestApi < ActionWebSerivce::API::Base       api_method :some_method, :expects => [{:foo => :string}]
   end

   tag 'mytest:action' do |tag|
      if request.post?
         # some code to get posted values
         myval = request.paremters['mytestvalue']
         if myval.empty?
            raise "No value."
         end
         mytest = ActionWebService::Client::Soap.new(MyTestApi, "http://someapiurl/", :handler_name => "some_handler"
         mytest.some_method(myval)
      end
   end
end

So that’s it in a nutshell. Wrap your tags and an Api class in the same module. You can call your Api methods from your tag definitions to execute the services you need.

Radiant CMS Search Extension

I was evaluating Radiant CMS for a site Kyle and I are developing, and couldn’t for the life of me find any documentation for the Radiant CMS search extension (though there was a thorough doc for the mailer extension). So here’s a little example of what I came up with looking at the ruby code for the extension itself.


<r:search:form label="" />
<r:search:empty>
   <h2>No Results</h2>
</r:search:empty>
<r:search:results>
   <h2>Search Results</h2>
   <r:search:results:each>
      <r:search:results:content />
   </r:search:results:each>
</r:search:results>

In a nutshell, this will show “No Results” in an h2 tag if there were no results found, otherwise, the search results for the query will be displayed below the search form.

Here are some of the search tags

  • <r:search:form> will display the search form (I modified the code to add the button)
  • <r:search:empty> renders the html block if there are no results
  • <r:search:results> renders the html block if there are results
  • <r:search:results:each> renders search results
  • <r:search:results:each:content> will render the content of each search results