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: http://scottstuff.net/blog/articles/2005/11/08/typo-theme-engine 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 :) Cheers -Tim -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ahh I did it :)
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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---