Typo Sidebar - CalendarHelper

One of the sidebar plugins I wrote needed a calendar. I decided to use Jeremy Voorhis’s calendar-helper. There are examples on his page on how to use it so I won’t go into those details here. The reason for this post is about how to get it working with Typo.

It proved fiddly because after putting the file in the ‘components’ directory made it visible in my controller class (with require 'calendar-helper' and include CalendarHelper) but not in ‘content.rhtml’. After a lot of Googling I found that the component needed to be installed as a global view helper. Those instructions aren’t the clearest, so here’s what you need to do:

  1. Install calendar_helper.rb to /typo/vendor/plugins/calendar_helper/lib
  2. In calendar_helper.rb change module CalendarHelper to module ActionView::Helpers::CalendarHelper
  3. At the bottom of calendar_helper.rb (after the last end) add
    ActionView::Base.send(:include, ActionView::Helpers::CalendarHelper)
  4. Create a file: ‘/typo/vendor/plugins/calendar_helper/init.rb‘ and put in it:
    require 'calendar_helper'
    

And after those four easy steps the ‘calendar’ function is now available in ‘content.rhtml’.

Spread the word: Technorati related  |  Technorati related  |  del.icio.us bookmark it!  |  submit Typo Sidebar - CalendarHelper digg.com digg it!  |  reddit reddit!

One Response to “Typo Sidebar - CalendarHelper”

  1. A Fresh Cup » Blog Archive » An Unexpected Hoop says:

    […] I added the DynamicCalendarHelper plugin to my current Rails project today, only to discover that I couldn’t call it the way that I expected from a view. Eventually I found the answer at Typo Sidebar - CalendarHelper which had instructions for turning the plugin into a global view helper. I was expecting a somewhat more seamless experience. […]

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>