ActionView theme hack?

Hey guys

I am needing to implement a theme type functionality in my app, I guess
one thats similar in operation to the way typo works with the theme
.rhtml files override the default view behavior. I found this blog post
about how the typo implementation works:

However when you look at hte source for the newest version, the
methodology for how it works seems te be very different and they dont
use that hack anymore. Would someone be able to lend an insight as to
why/how the current implementation works, as its tottally not obvious!
There are notes in the source that there overideing undocumented rails
methods, but even when comparing there overrides with the rails source
itself, things dont become clear!

Any advice on implementing a themeing system would be greatly
appreciated :slight_smile:

Cheers

-Tim

Ahh I did it :slight_smile:

For anyone who is interested, its purley a matter of having the
following in a helper file:

NB: This overrides an undocumented rails function in order to add

a search path. We need this to get themes working, but I’d be

happier if we didn’t have to override undocumented methods. Ho

hum. – pdcawley

def search_paths
["…/…/themes/#{this_site.theme.name}/views", # for normal views
“.”,
“…/app/views”]
end

def full_template_path(template_path, extension)
search_paths.each do |path|
themed_path = File.join(@base_path, path,
“#{template_path}.#{extension}”)
return themed_path if File.exist?(themed_path)
end
# Can’t find a themed version, so fall back to the default behaviour
super
end

and having the appropriately set models. Also, check out cached_model
project, as that is very useful for performance enhancing when calling
the same method many times on one request.

Tim