JK Sieber said the following on 29/12/07 03:52 AM:
Is there any thing in RoR (plug-ins, or etc) that will simplify the layout problem abstracting much of the HTML/CSS conundrum?
Once you get past the basics (working though the example in AWDWR is a good start, as well as various screencasts that are available), you can look at "Modular Page Assembly with Rails".
Unless/until you understand the basics of templates and partials, that paper won't make sense. When you do it ill produce, as it seems to for many people, a "wow!" reaction. You may or may not like it, but ..
So somewhere along the line you can have a partial that looks something like
<%= content_for(:head) do %> <%# Comment: the css that this needs %> <%= stylesheet_link_tag "leftsidebar" %> <% end %> <%= content_for(:leftsidebar) do %> <% render ( :partial => controller_action_name + "_left", :locals => { :menu => @menu_left, :adverts => @adverts } ) rescue nil %> <% end %>
That way you can have a sidebar that is slightly different for 'list', 'view' and 'edit'. For example, you might want 'edit' not to have the menu and other panels that could take the user away from editing without doing either 'save' or 'cancel' (which might matter if the record was locked) and insert a "help" listing instead.
Why the CSS? Well, it helps in development even if it does cost in browser performance :-/ One way it is useful, though: If you are doing table-less CSS driven multi-column you'll have lines like
#contain { padding-left: 200px; padding-right: 190px; overflow: hidden; }
This creates 'gaps" so that the left and right 'panels' can be shifted in there:
#left { width: 180px; padding: 0 10px; right: 240px; margin-left: -100%; } * html #left { left: 150px; }
But what if the left panel says "Poof!" - there is no left panel, we're in edit mode and we want a full screen (see above for reasons).
Well, you could specify that 'edit' uses a different layout, but then you'd have the problem of keeping the look and feel consistent, which is the common problem. So we get back to templates and modular assembly. Why have different templates for each action rather than different partials for each action?
Go toss a coin. YMMV.
But a left panel specific CSS could alter the "content" to make a space for itself. Heck, that way not only could different actions have different sidebar content, they could have different sidebar size and colour and ... Hmm. Mouseover to pop-up ..?
The imagination boggles. My imagination has just run ahead of my skill.
Oh, and take a look at TabNav, part of the widget toolkit from SeeSaw. http://www.seesaw.it/en/toolbox Great stuff, and it uses the "content_for" in ways you can learn from. And CS, but I've yet to master that part of it 