SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Drupal 7.x and odd behavior with a title... (Something to do with escaping chars?)

    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:

    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.

  2. #2
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind... Turned out that the view I was using wasn't allowing markup to be inserted into the values of each result's link fields that I was using... For some reason, this caused some escaping issues with that specific title I used above... So allowing markup to be used in the values allowed it to display properly. Now granted, this isn't preferable because it should display the title regardless, but whatever. It's working now and I'm not too worried about allowing markup to be placed in these fields because I can limit which tags are used.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •