如何将参数传递给引用其他页面的zend_navigation

时间:2010-08-31 14:55:02

标签: php zend-framework

$pages = array(
       array(
          'label'    => 'Search',
          'title'    => 'Please Search',
          'uri'      => 'Search.php',
          'params'   => array('stcode'=>$stcode)
        ));

现在,pages数组将被传递给zend_naviagtion

 $container = new Zend_Navigation($pages);
 $view->getHelper('navigation')->setContainer($container);

我在pages数组中有几个项目可以帮助我显示菜单 当我点击该搜索页面时生成菜单 如果当时不存在stcode,则会将我带到index.php,因为代码已写入 它将重定向到index.php。现在我的问题是如何将stcode传递给该页面

1 个答案:

答案 0 :(得分:1)

你的意思是通过ZF请求对象这样做:

$this->getRequest()->setParam("stcode", $the_value);

然后可以这样访问

$this->getRequest()->getParam("stcode");

// You can also pass an optional default value
$this->getRequest()->getParam("stcode", "wibble");

或者像这样

// This has no default value and may return an error depending on your configuration
$this->getRequest()->stcode;