Hello I need to make site views changeable I found how to change layouts but it is not enough, becouse templates can use different ways to display and organize content. I found one way to do this, but i need to make subfolders in my ''view/layouts'', ''view/controller_name'' both and to create additional subfolder somewhere in ''public'' to put there tepmlate images, styles, js etc. Is there any options to tell rails to look for views in the other places, not in ''app/view'' ? -- Posted via http://www.ruby-forum.com/.
why not put images, styles and js in the appropriate folders that exist already? (Except the images one... you would need to create that one) On 4/27/06, Kostya <kostya.sys@gmail.com> wrote:> > Hello > > I need to make site views changeable > I found how to change layouts but it is not enough, becouse templates > can use different ways to display and organize content. > I found one way to do this, but i need to make subfolders in my > ''view/layouts'', ''view/controller_name'' both and to create additional > subfolder somewhere in ''public'' to put there tepmlate images, styles, js > etc. > > Is there any options to tell rails to look for views in the other > places, not in ''app/view'' ? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060427/45aee321/attachment.html
the problem is not in place for images i just want to have all files related to some template in one folder maximum 2 folders 1 - for views and layouts 2 - public folder for images and other browsable things in php whith smarty it would be something like that $smarty->templates_dir = "/path/to/my/templates" so $smarty->display("index.tpl") will render /path/to/my/templates/index.tpl but rails somehow knows that all views are in /rails/app/view is it passible to change this path inside the controller dinamicly ? -- Posted via http://www.ruby-forum.com/.
Kostya wrote:> the problem is not in place for images > i just want to have all files related to some template in one folder > maximum 2 folders > 1 - for views and layouts > 2 - public folder for images and other browsable things > > in php whith smarty it would be something like that > $smarty->templates_dir = "/path/to/my/templates" > so > $smarty->display("index.tpl") > will render > /path/to/my/templates/index.tpl > > but rails somehow knows that all views are in /rails/app/view > is it passible to change this path inside the controller dinamicly ?It''s quite simple. In your controller just put: @response.template.base_path = "/absolute/path/to/template/root" render(:action => ''index'') (see: http://ragnarson.blogspot.com/2006/04/dynamic-templateroot-revisited.html and http://ragnarson.blogspot.com/2006/03/dynamic-templateroot.html) But do not be tempted to put everything (templates, images) in one place. It is a very bad decission. Rather get used to current setup. Remember, that generated html code should be strictly semantical and site look should be defined by CSS. In that sense html is completly unrelated to visual effect (see http://csszengarden.com for examples). Cheers, ?ukasz -- Posted via http://www.ruby-forum.com/.
On Apr 27, 2006, at 1:46 AM, ?ukasz Piestrzeniewicz wrote:> Kostya wrote: >> the problem is not in place for images >> i just want to have all files related to some template in one folder >> maximum 2 folders >> 1 - for views and layouts >> 2 - public folder for images and other browsable things >> >> in php whith smarty it would be something like that >> $smarty->templates_dir = "/path/to/my/templates" >> so >> $smarty->display("index.tpl") >> will render >> /path/to/my/templates/index.tpl >> >> but rails somehow knows that all views are in /rails/app/view >> is it passible to change this path inside the controller dinamicly ? > > It''s quite simple. In your controller just put: > > @response.template.base_path = "/absolute/path/to/template/root"Please don''t do that! At the very least, make a CONSTANT in config/environment.rb and use that rather than a string somewhere in your source code. Better yet, figure out a way to handle it relative to RAILS_ROOT so that if you move your app around in the filesystem, it will still work. -- -- Tom Mornini