开发者

How do I read the url parameters from a ZendFramework Controller

I have a ZendFramework controller whose view 开发者_如何学Cforms a framework similar to this:

http://foo.com/#/controler/someaction/state/city/address/

The action looks like this:

public function someactionAction()
{
    $this->view->someaction = App_Model_WebService_Menu::getInstance()->getRows(array(
        'address' => '1600 Pennsylvania Ave',
        'returnRecordsLimit' => 1,
    ));    
}

Is there a way where I can access state, city and address as parameters?


From Zend_Controller_Request documentation

$state   = $this->getRequest()->getParam('state');
$city    = $this->getRequest()->getParam('city');
$address = $this->getRequest()->getParam('address');


Ignoring the URL fragment part which I assume is reliant on some JavaScript configuration, that looks like it would be part of a custom route, ie

:controller/:action/:state/:city/:address

You will have to look into the route definition to discover the actual parameter names, after which you simply use (from your controller)

$state = $this->_getParam('state-param-name');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜