By joel_guesclin on
I'm mucking around with a phptemplate theme, and I want to build a link myself. The link is going to be text, and I want to add the "onmouseover" and "onmouseout" commands into it. Wanting to do things the right way, I'm trying to use the "l" (pronounced "el") function to do this. Here is the code:
$title_attribs['onMouseover'] = '"ddrivetip(\'fixedtipdiv-' . $node->nid . '\', \'400\')';
$title_attribs['onMouseout'] = '"hideddrivetip()"';
$cell['data'] = l($node->node_title, "node/$node->nid", $title_attribs, NULL, NULL, FALSE, FALSE);
This sort of works - but the problem is that it produces stuff like this:
<a href="/drupal-4.7.4/usa/exciting" onMouseover=""ddrivetip('fixedtipdiv-21', '400')" onMouseout=""hideddrivetip()"">A test thingy by USA</a>
As you can see, it's turning all the command stuff into html entities - is there any way around this, other than building the link completely by hand?
Comments
You've got some extra double
You've got some extra double quotes in there. The
l()function adds the double quotes for you, so you don't need to place them inside the attribute value strings. When you do, they get converted. Just remove them.'Fraid that still doesn't work
You're right about there being extra double-quotes - however, once I sort that out the single-quotes remaining still get converted so that the single quotes are being displayed as html entities
hmm... you're right
The attributes get passed to drupal_attributes which filters them through check_plain, so I don't think there's any way around this. Shouldn't stop the javascript from working though.