zend_navigation和onclick属性 [英] zend_navigation and onclick attribute
本文介绍了zend_navigation和onclick属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以推入zend_navigation页面类型mvc或uri并将其赋予onclick属性?
is there any way how to push into zend_navigation page type mvc or uri and give it onclick attribute?
array (
'type' => 'uri',
'label' => 'Map',
'title' => 'Map',
'uri' => '#',
'click' => 'alert("show map");' )
i的子子菜单包含仅触发模式的链接.直到现在,我仍使用自己的导航"解决方案,但我想使用zend的解决方案.
i have sub sub menus included links which fires only modal. till yet i use my own "navigation" solution but i want to use zend´s one.
谢谢
推荐答案
您可以编写自己的菜单帮助程序,而不是 Navigation_Menu 帮助程序.
You can write your own menu helper instead of Navigation_Menu helper.
扩展的主要方法是 htmlify :
class MyApp_View_Helper_MyMenu extends Zend_View_Helper_Navigation_Menu
{
public function htmlify(Zend_Navigation_Page $page)
{
// ... put original code here ...
// get attribs for element
$attribs = array(
'id' => $page->getId(),
'title' => $title,
'class' => $page->getClass()
);
// does page have a href?
if ($href = $page->getHref()) {
$element = 'a';
$attribs['href'] = $href;
$attribs['target'] = $page->getTarget();
$attribs['onclick'] = $page->getClick(); // the click attribute
} else {
$element = 'span';
}
return '<' . $element . $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($label)
. '</' . $element . '>';
}
}
然后,通过以下方式致电您的助手:
Then, call your helper via:
<?php echo $this->navigation()->myMenu(); ?>
在此处查看完整示例:获取Zend_Navigation与jQuery的Fisheye一起使用的菜单
see full example here: Getting Zend_Navigation menu to work with jQuery's Fisheye
这篇关于zend_navigation和onclick属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文