Posted by Sivert on April 27, 2012 at 11:08am
7 followers
| 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="
<?phpprint $class;
?>
$attributesis the default container of class, as I understand it.#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
.
#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.
#7
As dawehner mentioned in #2, any patches will probably need to be using the process/preprocess functions to manage this instead.
#8
+++ 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.