Hi all, I''m using the tabnav plugin for a community project and I think it is quite comfortable to use. But, when I have many tabbed screens in my app, I have to generate many corresponding xyz_tabnav.rb models. Now for each of these models there seems to be one template xyz_tybnav.rhtml which contains the style for the corresponding tabnav. In my app ALL tabbed screens will have the SAME style (as I would assume for most apps in general). Does it mean that I have to maintain many of these style files for all the tabbed screens redundantly? Or can I consolidate the one style for all tabbed screens? Cheers, Star -- 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 -~----------~----~----~----~------~----~------~--~---
I modified the ''def tabnav tabnav_sym method'' from tabnav''s application_helper_extension.rb to check the tabnav_sym to determine the object being rendered. Based on that information, I select the partial to use for the rendering. I do a bit of code in the application.rhtml layout using @first_render or getting the controller name directly to select the tabnav to display and pass that to the start tabnav tag. I now have two partials (two nested tab styles) that replace what would have been over 15 tabnav partials for my application. I don''t know if this will work with the newer versions, but it solved my problem. Example with a nested tabnav: app/views/layouts/application.rhtml: <%= render_partial ''common/header'' -%> <%= start_tabnav :main -%> <% case @first_render when /^admin/ tabnav_set = :admin when /^home/ tabnav_set = :home end %> <%= start_tabnav tabnav_set -%> <!-- start content --> <%= yield -%> <%= end_tabnav -%> <!-- end content --> <%= end_tabnav -%> <%= render_partial ''common/footer'' -%> tabnav application_helper.rb: # Selects the correct template to use for rendering the selected # tabnav object. def tabnav tabnav_sym # Set the name of the template if tabnav_sym.id2name == ''main'' tabnav_template = ''main'' else tabnav_template = ''secondary'' end # Render the tabnav partial result = capture do render :partial => "tabnav/#{tabnav_template}_tabnav", :locals => { :tabs => tabnav_sym.to_tabnav.tabs } end result end On Mar 6, 6:46 am, Star Burger <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > I''m using the tabnav plugin for a community project and I think it is > quite comfortable to use. > > But, when I have many tabbed screens in my app, I have to generate many > corresponding xyz_tabnav.rb models. Now for each of these models there > seems to be one template xyz_tybnav.rhtml which contains the style for > the corresponding tabnav. > > In my app ALL tabbed screens will have the SAME style (as I would assume > for most apps in general). Does it mean that I have to maintain many of > these style files for all the tabbed screens redundantly? > > Or can I consolidate the one style for all tabbed screens? > > Cheers, > > Star > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Sounds good. Another solution could be to change the tabnav renderer in a way that not the tabnav class name is used to generate the style name but that a style name could be set via a method "set_style" in the tabnav class definition (like "add_tab"). KRD wrote:> I modified the ''def tabnav tabnav_sym method'' from tabnav''s > application_helper_extension.rb to check the tabnav_sym to determine > the object being rendered. Based on that information, I select the > partial to use for the rendering. I do a bit of code in the > application.rhtml layout using @first_render or getting the controller > name directly to select the tabnav to display and pass that to the > start tabnav tag.-- 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 -~----------~----~----~----~------~----~------~--~---
You can specify the Tabnav''s class prefix with: class BasicTabnav < Tabnav::Base html_options :class => ''inner_tabnav'' add_tab ... end end This overrides the default class naming, so you can share the same style for every Tabnav. Then I''d remove the partials and move my CSS code inside the main .css file. -- 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 -~----------~----~----~----~------~----~------~--~---
Paolo Dona wrote:> You can specify the Tabnav''s class prefix with: > > class BasicTabnav < Tabnav::Base > html_options :class => ''inner_tabnav'' > > add_tab > ... > end > end > > This overrides the default class naming, so you can share the same style > for every Tabnav. Then I''d remove the partials and move my CSS code > inside the main .css file.Thanks! That was the only thing missing... -- 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 -~----------~----~----~----~------~----~------~--~---