Hi!
This patch enhances table as well as grid views by some styles I have missed so far and referring to #364637: Let table rows emit custom classes.
The first row of a view gets the class views-row-first, the last one accordingly views-row-last. There is one exception: If there is only one single row, its classes are not both views-row-first and views-row-last, but views-row-single instead.
In addition to $row_classes there is also an array $col_classes with similar class names (views-col-first, views-col-last, views-col-single, views-col-odd, views-col-even).
Furthermore, I have moved php code from the grid template to the grid preprocess function and renamed row-first/row-last as views-row-first/views-row-last.
I left the implode function in the template file, though I'd personally prefer not to use it there, since it opposes the paradigm that a designer should understand the whole template source. Otherwise, I see the advantage of manipulating an array of classes within further preprocess functions over working with a string. Unfortunately, I cannot offer a better solution, so it would be great, if anyone had a better idea.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | views-grid-and-table-v2.patch | 6.22 KB | drupalexio |
| #1 | views-grid-and-table.patch | 4.4 KB | drupalexio |
Comments
Comment #1
drupalexio commentedComment #2
dawehnerI like to move logic from the template into preprocess, but sadly there are some minor things
I don't like $fields as variable here, its $field_id, or something similar.
It would be better for people if you have inline comments where you describe what reset key and end does here.
Comment #3
drupalexio commentedIn terms of the variable name $fields I completely agree with you and have renamed it as $field_id. I did the same within views-view-table.tpl.php.
In addition, I have also added the wanted inline comments.
Finally, I have added some missing lines in the comment head of the templates.
Comment #4
kars-t commentedThis is a great and use full patch. Please commit it!
Comment #5
dawehnerRelated issue: http://drupal.org/node/682888
Can you please have a look where the implode should be done? in template file or preprocess
Sorry for this.
Comment #6
kars-t commentedAs you did show me on IRC the only option to avoid this in D6 would be to do some special hook_theme implementation like this ZEN theme is doing. So I'd still say go for it. I will try to catch earl on IRC to talk about this. Hope I find some time. Otherwise maybe he stumbles about this issue and likes it ;)
Comment #7
dawehnerSorry but
Comment #8
dawehnerUpdate status
Comment #9
esmerel commentedNo updated to patch in over 3 months.