Domanda

I need to use CHtml::link() inside " ".

Here is my existing code:

    $html .="<li>\n <a href='books".$menu['items'][$itemId]['link']."'>
                     ".$menu['items'][$itemId]['label']."
                    </a> \n";

    $html .= buildMenutree($itemId, $menu);

    $html .= "</li> \n";

I hope I can find a nice solution.

È stato utile?

Soluzione

You can use the CHtml function in your string just as any other PHP function:

$html .="<li>\n " . CHtml::link($menu['items'][$itemId]['label'], $menu['items'][$itemId]['link']);

See normalizeUrl for the url's you can use.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top