Question

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.

Was it helpful?

Solution

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.

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