Question

I don't know if I'm doing this right, probably not.

Basically I'm trying to concatenate with some IF conditions. I just got knowledge of thernary operation. Checking the code in firebug, I see some extra space is added between two classes which causes some problem.

enter image description here

So far here is the code:

<?php 
    $output .= '<span class="ca-icon '.
    (($category->getId()==3)||($category->getId()==4)||($category->getId()==5)||($category->getId()==6)||($category->getId()==7) ? " activeMenuLink " : "").'
    icon-'. strtolower(str_replace($characters,$replacements,Mage::helper('pronav')->__($data['name']))).'"></span>';
?>
Was it helpful?

Solution

This should do the trick:

<?php 
    $output .= '<span class="ca-icon '.
    (($category->getId()==3)||($category->getId()==4)||($category->getId()==5)||   ($category->getId()==6)||($category->getId()==7) ? " activeMenuLink " : "")
.'icon-'. strtolower(str_replace($characters,$replacements,Mage::helper('pronav')->__($data['name']))).'"></span>';
?>

OTHER TIPS

In your original code, there were a litteral new line at the end of line 3, and a few litteral spaces at the beginning of line 4.

Notice the openning "quote" at the end of line 3. This is where your litteral string started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top