Closed (works as designed)
Project:
Views PHP
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Jun 2012 at 22:38 UTC
Updated:
25 Oct 2012 at 16:39 UTC
In short, this code works if I create a php field in a view:
$options = array('query'=>array('viewer' => $row->uid), 'attributes'=>array('title'=>'Share this'));
$link = l('share', 'node/' . $view->args[0], $options );
print $link;
But, if I try to add a class field to the attributes array:
$options = array('query'=>array('viewer' => $row->uid), 'attributes'=>array('class'=>'share', 'title'=>'Share this'));
$link = l('share', 'node/' . $view->args[0], $options );
print $link;
I get this error:
Fatal error: [] operator not supported for strings in /home/content/97/9512397/html/includes/common.inc on line 2353
This seems to be caused by your module as this bug report suggests http://drupal.org/node/1650762
Comments
Comment #1
NoRandom commentedExtra information:
The problem seems to be related to the fact that the created link could already have, under certain circumstances, other classes (i.e. "active" if the link leads to the same url you're viewing).
In case someone needs a workaround while the bug is solved, you can alter the link after it's created for adding your extra classes:
Comment #2
sirajs commentedI had this problem when trying to use the following on a node that wasn't a in the teaser viewmode:
In my case, at least, my suspicion is that this is because the attribute is not defined outside of the context of a teaser.
Comment #3
ecommercium commentedHi,
I just deleted the [] in $options['attributes']['class'][] = 'active'; (#2358 in common.inc. But, this is a workaround for me and should not have to edit things in core!
Can someone have a look at this? I had this after my site upgrade to 7.16 from .15 and had 'fixed' it in that too!
Cheers!
Comment #4
ttkaminski commentedPlease read the documentation. The class attribute must be an array. See this comment for a good example.