This is sort of how Zen and Drupal 7 are doing it. In D7 the $classes_array is done in _preprocess() and the $classes are flattened in _process(). This is close for D6 ;)

If you are cool with this, I can do a quick patch for panels too, to make it consistent.

Comments

merlinofchaos’s picture

Can we do the same for the major styles? In particular I think the unformatted style wants it, and the fields row style wants this?

jacine’s picture

Assigned: Unassigned » jacine

Sure, why not ;)

jacine’s picture

StatusFileSize
new3.38 KB

Hey, sorry for the delay here. I did the unformatted style, but the fields were a little hairy because the label and the field wrapper class are both using the $field->class variable. I played with it a little, but think what you have now is better in the end.

<<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
<label class="views-label-<?php print $field->class; ?>">

Note: the template file for views-view-unformatted.tpl.php didn't need any changes, since it's already printing $classes[$id].

If you wanted more/something else, let me know :)

johnalbin’s picture

subscribe.

dawehner’s picture

There is another patch for the table which does the imploting in the template file. Which one is better?
implode in preprocess
implode in template file

jacine’s picture

@dereine preprocess is better. It makes for a cleaner template file.

merlinofchaos’s picture

Status: Needs review » Needs work

This patch needs to update the documentation at hte top of the template to reflect that the variables available have changed.

Also, I think this is a little too aggressive in removing stuff. $name is a useful variable to have, as is $display_id -- those shouldn't be removed.

jacine’s picture

Status: Needs work » Needs review
StatusFileSize
new3.75 KB

How's this?

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches! Thanks!

jacine’s picture

Yay! Thank you :D

jcmarco’s picture

Category: feature » bug
Status: Fixed » Needs review
StatusFileSize
new1.2 KB

Last patch breaks any unformatted view.

The template_preprocess_views_view_unformatted() function is using $vars['classes_array'] as an internal temporal array to build up the $vars['classes'],
only $classes[$id] are used in the template to define classes for every row div in the views-views-unformatted.tpl.php.

The problem is that $vars['classes_array'] is left there and the Zen theme or any D7 theme (http://api.lullabot.com/template_process/7) ,
transform every $vars['classes_array'] in a $vars['classes'] so it is trying to apply a $vars['classes'] = implode(' ', $vars['classes_array']);
but the $vars['classes_array'] is a multidimensional array, so you find in the html code than every unformatted views has on each row the next classes:
first row: 'A', second: 'r', third:'r'...'a'..... (guess next?)

This patch use a temporal array for building the $vars['classes'][$id]

karens’s picture

Linking to a similar issue in the D7 version. It may be that that fix (or a variation) will work here. See #753808: Notice: Array to string conversion in template_process().

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Committed to 6.x; needs porting to 7.x

dawehner’s picture

Status: Patch (to be ported) » Fixed

This kind of code is already in d7.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.