Hi, what''s the best way to display "modules" in a webpage? I want to add these little blocks on different pages like a random image block for example. For example the modules on the right on this page: http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html What''s the best way to do this? I heared something about partials/ components? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
pauljdavis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-18 22:03 UTC
Re: Modules / blocks on a page
The Hobo plugin has a feature for specifying layout via blocks which are shareable across an application, and lots of other Rails-enhancing stuff. Check it out at: http://www.hobocentral.net It''s really powerful and flexible. Pd On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Hi, what''s the best way to display "modules" in a webpage? > I want to add these little blocks on different pages like a random > image block for example. > > For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > What''s the best way to do this? I heared something about partials/ > components?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks. But I''m just beginning with Rails and I''m now making an ultra- simple application so I would like to do it myself. I feel that way I will understand rails better. So I''m looking for a way I can implement that functionality in a simple, standard-rails way. On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The Hobo plugin has a feature for specifying layout via blocks which > are shareable across an application, and lots of other Rails-enhancing > stuff. > > Check it out at: > > http://www.hobocentral.net > > It''s really powerful and flexible. > > Pd > > On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > Hi, what''s the best way to display "modules" in a webpage? > > I want to add these little blocks on different pages like a random > > image block for example. > > > For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > > What''s the best way to do this? I heared something about partials/ > > components?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Anyone else? On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Thanks. But I''m just beginning with Rails and I''m now making an ultra- > simple application so I would like to do it myself. I feel that way I > will understand rails better. So I''m looking for a way I can implement > that functionality in a simple, standard-rails way. > > On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > The Hobo plugin has a feature for specifying layout via blocks which > > are shareable across an application, and lots of other Rails-enhancing > > stuff. > > > Check it out at: > > > http://www.hobocentral.net > > > It''s really powerful and flexible. > > > Pd > > > On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > Hi, what''s the best way to display "modules" in a webpage? > > > I want to add these little blocks on different pages like a random > > > image block for example. > > > > For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > > > What''s the best way to do this? I heared something about partials/ > > > components?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
LeonB wrote:> Anyone else? > > On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > >> Thanks. But I''m just beginning with Rails and I''m now making an ultra- >> simple application so I would like to do it myself. I feel that way I >> will understand rails better. So I''m looking for a way I can implement >> that functionality in a simple, standard-rails way. >> >> On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> >>> The Hobo plugin has a feature for specifying layout via blocks which >>> are shareable across an application, and lots of other Rails-enhancing >>> stuff. >>> >>> Check it out at: >>> >>> http://www.hobocentral.net >>> >>> It''s really powerful and flexible. >>> >>> Pd >>> >>> On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: >>> >>>> Hi, what''s the best way to display "modules" in a webpage? >>>> I want to add these little blocks on different pages like a random >>>> image block for example. >>>> >>>> For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html >>>> >>>> What''s the best way to do this? I heared something about partials/ >>>> components? >>>> > > > > > >The easy way is to use instance variables to hold the data, perhaps set up using filters in the application controller -- @menus, @sidebars, etc, and then rendering using a partial if they have been set: render :partial => ''sidebar'' if @sidebar, for example. It can get more sophisticated than this, with a custom class for each type of furniture (one for menus, one for sidebars, etc), but hopefully this helps a little to start with. Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks. If I use a partial in my main layout and use an if in the partial. Like: if (:controller == ''dashboard'') (or something like that) would that be considered a hack? Is there a nicer way? On Mar 20, 8:39 pm, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> LeonBwrote: > > Anyone else? > > > On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > >> Thanks. But I''m just beginning with Rails and I''m now making an ultra- > >> simple application so I would like to do it myself. I feel that way I > >> will understand rails better. So I''m looking for a way I can implement > >> that functionality in a simple, standard-rails way. > > >> On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> wrote: > > >>> The Hobo plugin has a feature for specifying layout via blocks which > >>> are shareable across an application, and lots of other Rails-enhancing > >>> stuff. > > >>> Check it out at: > > >>> http://www.hobocentral.net > > >>> It''s really powerful and flexible. > > >>> Pd > > >>> On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > >>>> Hi, what''s the best way to display "modules" in a webpage? > >>>> I want to add these little blocks on different pages like a random > >>>> image block for example. > > >>>> For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > >>>> What''s the best way to do this? I heared something about partials/ > >>>> components? > > The easy way is to use instance variables to hold the data, perhaps set > up using filters in the application controller -- @menus, @sidebars, > etc, and then rendering using a partial if they have been set: render > :partial => ''sidebar'' if @sidebar, for example. It can get more > sophisticated than this, with a custom class for each type of furniture > (one for menus, one for sidebars, etc), but hopefully this helps a > little to start with. > Chris--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No, but there may be a better way of doing it, depending on what you''re going to be showing. If the furniture (for want of a better word) is substantially different on the dashboard controller, you may be better off with separate layout for that controller. Or if the partials are dependent on dynamic data, then set that data up in the method called by the filter (in my application controller I have before_filter :setup_layout_furniture), and do the testing againt the controller in the method called. The idea is to keep the views (and layouts) as clean, readable, and DRY as poss. LeonB wrote:> Thanks. If I use a partial in my main layout and use an if in the > partial. Like: > if (:controller == ''dashboard'') > (or something like that) > would that be considered a hack? Is there a nicer way? > > On Mar 20, 8:39 pm, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> LeonBwrote: >> >>> Anyone else? >>> >>> On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: >>> >>>> Thanks. But I''m just beginning with Rails and I''m now making an ultra- >>>> simple application so I would like to do it myself. I feel that way I >>>> will understand rails better. So I''m looking for a way I can implement >>>> that functionality in a simple, standard-rails way. >>>> >>>> On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>> wrote: >>>> >>>>> The Hobo plugin has a feature for specifying layout via blocks which >>>>> are shareable across an application, and lots of other Rails-enhancing >>>>> stuff. >>>>> >>>>> Check it out at: >>>>> >>>>> http://www.hobocentral.net >>>>> >>>>> It''s really powerful and flexible. >>>>> >>>>> Pd >>>>> >>>>> On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: >>>>> >>>>>> Hi, what''s the best way to display "modules" in a webpage? >>>>>> I want to add these little blocks on different pages like a random >>>>>> image block for example. >>>>>> >>>>>> For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html >>>>>> >>>>>> What''s the best way to do this? I heared something about partials/ >>>>>> components? >>>>>> >> The easy way is to use instance variables to hold the data, perhaps set >> up using filters in the application controller -- @menus, @sidebars, >> etc, and then rendering using a partial if they have been set: render >> :partial => ''sidebar'' if @sidebar, for example. It can get more >> sophisticated than this, with a custom class for each type of furniture >> (one for menus, one for sidebars, etc), but hopefully this helps a >> little to start with. >> Chris >> > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Is it possible to do a :before_filter that places it''s data in a specific div created in my main layout? On Mar 21, 12:18 am, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> No, but there may be a better way of doing it, depending on what you''re > going to be showing. If the furniture (for want of a better word) is > substantially different on the dashboard controller, you may be better > off with separate layout for that controller. Or if the partials are > dependent on dynamic data, then set that data up in the method called by > the filter (in my application controller I have before_filter > :setup_layout_furniture), and do the testing againt the controller in > the method called. The idea is to keep the views (and layouts) as clean, > readable, and DRY as poss. > > LeonB wrote: > > Thanks. If I use a partial in my main layout and use an if in the > > partial. Like: > > if (:controller == ''dashboard'') > > (or something like that) > > would that be considered a hack? Is there a nicer way? > > > On Mar 20, 8:39 pm, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > >> LeonBwrote: > > >>> Anyone else? > > >>> On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > >>>> Thanks. But I''m just beginning with Rails and I''m now making an ultra- > >>>> simple application so I would like to do it myself. I feel that way I > >>>> will understand rails better. So I''m looking for a way I can implement > >>>> that functionality in a simple, standard-rails way. > > >>>> On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >>>> wrote: > > >>>>> The Hobo plugin has a feature for specifying layout via blocks which > >>>>> are shareable across an application, and lots of other Rails-enhancing > >>>>> stuff. > > >>>>> Check it out at: > > >>>>> http://www.hobocentral.net > > >>>>> It''s really powerful and flexible. > > >>>>> Pd > > >>>>> On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > >>>>>> Hi, what''s the best way to display "modules" in a webpage? > >>>>>> I want to add these little blocks on different pages like a random > >>>>>> image block for example. > > >>>>>> For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > >>>>>> What''s the best way to do this? I heared something about partials/ > >>>>>> components? > > >> The easy way is to use instance variables to hold the data, perhaps set > >> up using filters in the application controller -- @menus, @sidebars, > >> etc, and then rendering using a partial if they have been set: render > >> :partial => ''sidebar'' if @sidebar, for example. It can get more > >> sophisticated than this, with a custom class for each type of furniture > >> (one for menus, one for sidebars, etc), but hopefully this helps a > >> little to start with. > >> Chris--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The before_filter just calls the method (which may call other methods), which sets up instance variables (which hold the data). So I have: <div id="menu_block"> <%= render :partial => "menu", :collection => @menus %> </div> In my case @menus is a collection of Menu instances, but you could easily have it as an array of links, strings, or whatever. Hope this makes sense, Chris LeonB wrote:> Is it possible to do a :before_filter that places it''s data in a > specific div created in my main layout? > > On Mar 21, 12:18 am, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> No, but there may be a better way of doing it, depending on what you''re >> going to be showing. If the furniture (for want of a better word) is >> substantially different on the dashboard controller, you may be better >> off with separate layout for that controller. Or if the partials are >> dependent on dynamic data, then set that data up in the method called by >> the filter (in my application controller I have before_filter >> :setup_layout_furniture), and do the testing againt the controller in >> the method called. The idea is to keep the views (and layouts) as clean, >> readable, and DRY as poss. >> >> LeonB wrote: >> >>> Thanks. If I use a partial in my main layout and use an if in the >>> partial. Like: >>> if (:controller == ''dashboard'') >>> (or something like that) >>> would that be considered a hack? Is there a nicer way? >>> >>> On Mar 20, 8:39 pm, Chris T <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>>> LeonBwrote: >>>> >>>>> Anyone else? >>>>> >>>>> On Mar 18, 11:58 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: >>>>> >>>>>> Thanks. But I''m just beginning with Rails and I''m now making an ultra- >>>>>> simple application so I would like to do it myself. I feel that way I >>>>>> will understand rails better. So I''m looking for a way I can implement >>>>>> that functionality in a simple, standard-rails way. >>>>>> >>>>>> On Mar 18, 11:03 pm, "pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <pauljda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>> wrote: >>>>>> >>>>>>> The Hobo plugin has a feature for specifying layout via blocks which >>>>>>> are shareable across an application, and lots of other Rails-enhancing >>>>>>> stuff. >>>>>>> >>>>>>> Check it out at: >>>>>>> >>>>>>> http://www.hobocentral.net >>>>>>> >>>>>>> It''s really powerful and flexible. >>>>>>> >>>>>>> Pd >>>>>>> >>>>>>> On Mar 18, 2:59 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: >>>>>>> >>>>>>>> Hi, what''s the best way to display "modules" in a webpage? >>>>>>>> I want to add these little blocks on different pages like a random >>>>>>>> image block for example. >>>>>>>> >>>>>>>> For example the modules on the right on this page:http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html >>>>>>>> >>>>>>>> What''s the best way to do this? I heared something about partials/ >>>>>>>> components? >>>>>>>> >>>> The easy way is to use instance variables to hold the data, perhaps set >>>> up using filters in the application controller -- @menus, @sidebars, >>>> etc, and then rendering using a partial if they have been set: render >>>> :partial => ''sidebar'' if @sidebar, for example. It can get more >>>> sophisticated than this, with a custom class for each type of furniture >>>> (one for menus, one for sidebars, etc), but hopefully this helps a >>>> little to start with. >>>> Chris >>>> > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---