I’m using Drupal 7.x with a custom view page that outputs various results, all with various links, etc., etc. I’m preprocessing some of the links so that I can control some of the link attributes (“class” being one of those attributes).
That said, I have one view result that has 1 link which has some special characters for its title / text.
The title that’s causing me some headaches is Foobar’s Office Computer for BLAH()
Whenever that title is output, something weird happens: the closing anchor tag disappears in the markup and causes some display issues.
Inside template.php, I have the following code:
if(<foobar condition>){
$vars->result[$a]->foobar_field[$b]['rendered']['#markup'] = l(t($vars->result[$a]->foobar_field[$b]['raw']['entity']->title),'node/'.$vars->result[$a]->foobar_field[$b]['raw']['entity']->vid,array('attributes'=>array('class'=>'alive')));
}else{
dpm(l(t($vars->result[$a]->foobar_field[$b]['raw']['entity']->title),'node/'.$vars->result[$a]->foobar_field[$b]['raw']['entity']->vid,array('attributes'=>array('class'=>'dead')));//Assigns a broken link (or assigns a good link, but outputs incorrectly...?));//Shows a correctly-constructed link.
$vars->result[$a]->foobar_field[$b]['rendered']['#markup'] = l(t($vars->result[$a]->foobar_field[$b]['raw']['entity']->title),'node/'.$vars->result[$a]->foobar_field[$b]['raw']['entity']->vid,array('attributes'=>array('class'=>'dead')));//Assigns a broken link (or assigns a good link, but outputs incorrectly...?)
}
When I output the link code with dpm()–a Devel function–the link shows perfectly fine… No problems at all.
But when I assign or override the original markup code with the new field value, the closing </a> tag is left off… Any ideas why? I keep assuming it has something to do with how l(t()) is interpreting the link text that has those special characters in it, but I dunno. At this point, I’m willing to believe anything because no matter what I do, it just doesn’t seem to output correctly.
Any insight or suggestions is appreciated.