Download & Extend

views-view-grid.tpl.php prints class twice

Project:Views
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:needs work

Issue Summary

If the view-grid has an attribute containing class, the class is property is printed twice, as in the following HTML excerpt:

<table class="views-view-grid cols-3" class="views-view-grid">

The code responsible for this is in views/theme/theme.inc and views/theme/views-view-grid.tpl.php.

views/theme/theme.inc, line 761:

<?php
$vars
['class'] = 'views-view-grid cols-' . $columns;
?>

views/theme/views-view-grid.tpl.php, line 16:
<?php
<table class="<?php print $class;
?>
"
<?php
print $attributes;
?>
>
?>

I am guessing there should be a check as to whether the $attributes string contains class, in which case the $class string should not be printed beforehand.

Comments

#1

Suggested patch: Remove class="

<?php
print $class;
?>
from template, since $attributes is the default container of class, as I understand it.
AttachmentSizeStatusTest resultOperations
views-view-grid-duplicate-class-1550486-1.patch559 bytesIgnored: Check issue status.NoneNone

#2

Oh removing something is probably bad. People might assume it exists for their custom templates.

what about checking the attributes class in the prepocess or in a process function?

#3

Do you have exact step to reproduce this? I can't reproduce this at the moment. I agree with #2 though, if we need to fix this, it should be done outside of the template.

#4

Status:active» postponed (maintainer needs more info)

.

#5

You can reproduce the bug simple creating a new view and choosing 2x2 grid layout.

#6

Here is a quick patch, please test it. I suggests to remove $attribute againt of $class, because the content of $attributes is included in $class variable.

AttachmentSizeStatusTest resultOperations
views-view-grid.tpl_.patch622 bytesIgnored: Check issue status.NoneNone

#7

As dawehner mentioned in #2, any patches will probably need to be using the process/preprocess functions to manage this instead.

#8

Status:postponed (maintainer needs more info)» needs work

+++ b/theme/views-view-grid.tpl.phpundefined
@@ -10,9 +10,9 @@
+  <h3><?php print $title; ?></h3>  <h3><?php print $title; ?></h3>

Also printing the title twice doesn't seem to be what you expect.

#9

I stumbled into this error while validating my site as XHTML. Using Views 3 stable release, Omega Theme, and a lot of other modifications...

Unlike the original post, I was using a Views Table format, and the class was repeated twice.

I solved this quickly by overriding the views template for the table format, and deleted the print $attributes.

I know this is not the most ideal way, but I was not selecting any of the "table" element classes anyways.

Minor issue and easy fix.