Pale Horse
2010-Oct-15 13:03 UTC
Noughts and Crosses layout with a variable number of entries
I have a product listing of 9 per-page. The products on the far right and bottom row should NOT have a border on the aforementioned sides. So, similar to a noughts and crosses layout. However, pages do not always have 9 products to display. You may have a better understanding if you see the code I''m currently using: http://pastie.org/1223260 The code above is passed inside a block and executed on each product in the products array. I cannot get the specified lines to disappear or wrap my head around this. I would *really* appreciate assistance with this. If you need more information, please reply with what you need to help me. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Felix Schäfer
2010-Oct-15 13:19 UTC
Re: Noughts and Crosses layout with a variable number of entries
Am 15.10.2010 um 15:03 schrieb Pale Horse:> I have a product listing of 9 per-page. The products on the far right > and bottom row should NOT have a border on the aforementioned sides. So, > similar to a noughts and crosses layout. However, pages do not always > have 9 products to display. > > You may have a better understanding if you see the code I''m currently > using: http://pastie.org/1223260 > > The code above is passed inside a block and executed on each product in > the products array. > > I cannot get the specified lines to disappear or wrap my head around > this. I would *really* appreciate assistance with this.That seems complicated as hell… Why not just make divs for the "rows" and in that divs for the "cells", and only output those divs as needed (yes, you already only output divs as needed, but the branching seems "too much"). Then try to find out what row or what cell adds which line. E.g. the second cell should have a left border to separate it from the first cell, same thing for the third cell. If you then have a fourth cell, you begin the second row, which then should have a top border to separate it from the first row, and so on. Thinking of it, the rule would be simple: output a div per product, group those in divs of 3 (the "rows"), mark the first "row" and the first "cell" of each "row" with a special class, and style every cell but the first of each row to have a left border, style each row but the first to have a top border. (oh, and you have style stuff in class attributes, and you shouldn''t have style stuff in your view in the first place, use classes and css.) Best, Felix -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Pale Horse
2010-Oct-15 14:57 UTC
Re: Noughts and Crosses layout with a variable number of entries
Apologies for omitting the code you provided - I needed to reduce the number of quoted lines. Thanks very much, I''ll give that a try. I should''ve considered the in_groups_of method before. I''ve actually hacked something together that seems to have worked. I''ll report back with my results. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ar Chron
2010-Oct-15 15:05 UTC
Re: Noughts and Crosses layout with a variable number of entries
Pale Horse wrote in post #951715:> Apologies for omitting the code you provided - I needed to reduce the > number of quoted lines. > > Thanks very much, I''ll give that a try. I should''ve considered the > in_groups_of method before. >Bah, my last_col_pos calc is wrong... rather than group.length-1, try group.nitems-1 Taht should ignore any nils added if there aren''t 3 items in a group -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.