2009年4月2日星期四

Re: [fw-mvc] Access the name of the controller from a View_Helper script.

> <?php
>
> class Zend_View_Helper_Nav extends Zend_View_Helper_Abstract {
>
> /* Return appropriate navigation based on controller */
> public function nav() {
>
> $controller =
> Zend_controller_Front::getInstance()->getRequest()->getControllerName();
>
> if ( $controller != 'admin' ) {
> $nav = file_get_contents(dirname(__FILE__).
> '/defaultNav.php');
> } else {
> $nav = file_get_contents(dirname(__FILE__). '/adminNav.php');
> }
> return $nav;
> }
>
> }

没有评论: