Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top