When using jcarousel with views I get Notice: Uninitialized string offset warnings for line 11 of the includes/jcarousel-view.tpl.php file if the number of nodes the view is displaying is greater than 14.
The error is due to $classes[$id] being empty - prior to that it id displaying consecutive letters in the string "jcarousel-view" - which has 14 letters.
While this doesn't effect the carousel and the notices are not shown with warnings switched off - it'd be great to fix this as is a pain in developer mode and also googling "jcarousel notice: Uninitialized string offset" brings up other sites that have this displayed so some users probably don't realize it's showing?
This is the fix I've used which works:
<ul class="<?php print $jcarousel_classes; ?>">
<?php foreach ($rows as $id => $row): ?>
<?php if (isset($classes[$id])) { ?>
<li class="<?php print $classes[$id]; ?>"><?php print $row; ?></li>
<?php } else { ?>
<li><?php print $row; ?></li>
<?php } ?>
<?php endforeach; ?>
</ul>
Is there a need for the $classes[$id] to be added?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | jcarousel_classes_notice.patch | 1.01 KB | quicksketch |
Comments
Comment #1
ytsurkconfirmed temporary fix for the mentioned warnings
thx
Comment #2
joostvdl commentedTried the fix also, which works.
Comment #3
quicksketchThis is because D7 hijacks the variable name "classes for its own purposes, making it so contrib modules cannot use that same variable name. This patch corrects the problem by using the name $row_classes instead. Committed to D7 branch only.
Comment #4
quicksketch