2009年4月2日星期四

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

As Zend_Navigation is still in development, you might want to check
out Zym_Navigation instead, the component on which Zend_Navigation is
based.

Documentation: http://www.zym-project.com/docs/reference/zym.navigation.html
Download: http://www.zym-project.com/download


On 1 apr 2009, at 15:06, J DeBord wrote:

> I would like to access the name of the controller from a View_Helper
> script.
>
> I think I could figure out how to explicitly pass it to the view,
> but I don't want to have to do this in every Controller.
>
> Any comments regarding how to generate navigation in the layout
> script based on which controller is being called are welcome as
> well. Especially if I am not going about it the best way. See code
> below.
>
> Thanks!
>
> <?php
>
> class Zend_View_Helper_Nav extends Zend_View_Helper_Abstract {
>
> /* Return appropriate navigation based on controller */
> public function nav() {
>
> $controller = ????????????????????????
>
> if ( $controller != 'admin' ) {
> $nav = file_get_contents(dirname(__FILE__). '/
> defaultNav.php');
> } else {
> $nav = file_get_contents(dirname(__FILE__). '/
> adminNav.php');
> }
> return $nav;
> }
>
> }

没有评论: