Some help need with syntax

Discussion in 'CSS' started by dbl07dee, Apr 5, 2008.

  1. #1
     
    if ($config['mod_rewrite'] == 'YES') { 
                        $template_listing->set('www', '<a href="'.BASE_URL.'/out-'.$f['selector'].'.html" target=_blank class=textlink>'.$lang['listing_visit_website'].'</a>');
                    } else {
                        $template_listing->set('www', '<a href="'.BASE_URL.'/listing_out.php?id='.$f['selector'].'" target=_blank  class= textlink>'.$lang['listing_visit_website'].'</a>');  
    
    PHP:
    the class textlink is set as a clickable link
    the font is adjusted with css
    a.textlink{font-weight:bold;color:#FF0000;font-size:14px;}

    the problem is the syntax of textlink to produce the desired font or is something else required?

    I 've tried "textlink" and 'textlink' and '"textlink'" to no sucess.

    Any thoughts or sugestions would be appreciated.
     
    dbl07dee, Apr 5, 2008 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    uhm... first if that variable is a boolean, you shouldn't be bothering with a string compare. Second, you're only changing a small part, so inline the conditional - third, you should ALWAYS put all html values in quotes... Fourth target should never be used unless you are using framesets because it's a total miserable /FAIL/ so far as accesability goes (it was deprecated for a REASON PEOPLE!!!)

    and frankly, I'd not bother stating that the class is an anchor since it's a waste of code... Though I'd have to see the surrounding code since you should probably be inheriting properties off the parent saving a class in the first place.

    But as it is now - I'd reduce that code to:

    $template_listing->set('www','<a href="'.BASE_URL.'/'.(
    	($config['mod_rewrite'] ? 
    		'out-'.$f['selector'].'.html' :
    		'listing_out.php?id='.$f['selector']
    	).'" class="textlink">',$lang['listing_visit_website'].'</a>'
    );
    Code (markup):
    TECHNICALLY I'd say all of your versions theoretically should work, without quotes, with single or with double - BUT without quotes is invalid markup in a 'modern' doctype, and single quotes would have to be 'escaped' to work properly since you are using single quotes in your PHP - which is good. I always use single quotes for php code and doubles in the markup output by it - keeps the code simple and avoids nested headache nightmares like '\''.$var.'\''

    Mind you if that variable is NOT boolean and for some ****ed up reason is storing a yes/no value as a string - then you'd need to put the =='YES' back in.
     
    deathshadow, Apr 5, 2008 IP
  3. dbl07dee

    dbl07dee Member

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I have tried everywhich way to escape and even change the css to no success.
    the variable may be required, unless there is another way of doing it
      {
            if ($_GET['type'] == 'print') { 
                 $template_listing->set('www',$f['www']); 
            } else {
                if($config['js_click_counting'] == 'YES') {
                    $template_listing->set('www', '<script type="text/javascript" language="JavaScript">function JSClickTrack($url) { parent.location = $url; }</script><a OnClick="JSClickTrack(\''.BASE_URL.'/listing_out.php?id='.$f['selector'].'&method=JS\')" href="'.$f['www'].'"  target="_blank">'.$lang['listing_visit_website'].'</a>');    
                } else {
                    if ($config['mod_rewrite'] == 'YES') { 
                        $template_listing->set('www', '<a href="'.BASE_URL.'/out-'.$f['selector'].'.html" 'target="_blank"' class="textlink">'.$lang['listing_visit_website'].'</a>');
                    } else {
                        $template_listing->set('www', '<a href="'.BASE_URL.'/listing_out.php?id='.$f['selector'].'" 'target="_blank"'  class="textlink">'.$lang['listing_visit_website'].'</a>');  
                    
                    }
    PHP:
     
    dbl07dee, Apr 8, 2008 IP