Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top