i get this report, when i add this code in the views-view.tpl.php.
print 'display-'. $css_class;

It works fine, but Drupal say:
Notice: Undefined variable: css_class in include() (line 54 of D:\xampp\htdocs\testsite\sites\all\modules\views\theme\views-view.tpl.php)

Greetings Marcel

Comments

dawehner’s picture

Well what a wonder, the variable $css_class doesn't exist :)

Maybe you could check first whether $css_class is !empty().
Alternative we could fix the preprocess function to include a default value = ''.

bruno2’s picture

Hey,

thanks for your fast answer. I hope i don`t misunderstand you, but why should the $css_class not exist? It works very good, only the message from drupal mean there is a fault!

dawehner’s picture

Well it's only set if the user has defined a css, if the view has not, it's not set.

damiankloip’s picture

Status: Active » Needs review
StatusFileSize
new806 bytes

Here is a patch to set the css_class variable first, and also use drupal_html_class instead of the preg_replace, which I think should be fine?

tim.plunkett’s picture

Status: Needs review » Needs work

I like this approach.

dawehner’s picture

+++ b/theme/theme.incundefined
@@ -61,7 +63,7 @@ function template_preprocess_views_view(&$vars) {
+    $vars['css_class'] = drupal_html_class($css_class);

This lowercases the css classes, so it's a bit out of scope as the other parts of views, doesn't do that.

Task for myself: look at previous issues regarding css classes, because there were issues with this function.

damiankloip’s picture

Ah, ok, shall we switch it back to the preg_replace that was there before then?

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new449 bytes

OK, so we should just make sure the variable is set for now?

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Yeah keep it simple for now.

damiankloip’s picture

Assigned: bruno2 » Unassigned
dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, looks perfect :)

Committed to 6.x-3.x and 7.x-3.x

Status: Fixed » Closed (fixed)

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