the notion of "pages" is something more abstract than a
controller+action. Instead, I would use something like Zend_Navigation
(http://framework.zend.com/wiki/display/ZFPROP/Zend_Navigation).
Whatever you do, the basic idea would be to "abstract away" the pages
of your site into something of a more a higher level, and generate the
navigation from that.
On Wed, Apr 1, 2009 at 9:06 AM, J DeBord <jasdebord@gmail.com> 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;
> }
>
> }
没有评论:
发表评论