Re: HTML_Menu: Adding item states for spacers and grayed disabledlinks?
| From: | Hinnerk Voss | Date: | Tue, 07 Nov 2006 22:09:52 +0000 |
| Subject: | Re: HTML_Menu: Adding item states for spacers and grayed disabledlinks? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25732@lists.php.net to get a copy of this message | ||
Thanks Alexey - it works!
//menu.php:
function checkdisabled ($disabled, $li_disabled, $li_enabled) {
if ($disabled == 'true') {
return $li_disabled;
} else {
return $li_enabled;
}
}
$template->setCallbackFunction('check', 'checkdisabled');
//template.tpl:
func_check( {mu_disabled},
<li class="off">{mu_title}</li>,
<li><a href="{mu_url}">{mu_title}</a></li>
)
//menu array:
'home' => array(
'title' => 'Home',
'url' => '/index.html',
'disabled' => 'true'
)
Alexey Borzov wrote:
Hi, Hinnerk Voss wrote:I use the HTML_Menu_SigmaTreeRenderer for rendering my menu. How do I add two more states "deactivated" for grayed menu items without a link (disabled menu item for not-logged-in users) and "empty" as a spacer in the menu?You basically have two options: 1) Write your own renderer based on SigmaTree, 2) Use callback functions in templates. The renderer will pass additional keys it finds in the menu array to the template and your functions can take care of the presentation: func_check {menu_deactivated}, <span class="grey">{menu_title}</span>, <a href="{menu_url}">{menu_title}</a> )