12Mar/100
getParam() in Zend Framework
Posted by daniel-ionica
How do you use the getParam() Front Controller Parameter ?
usually in php your link should be somthing like:
user.php?action=aboutuser&username=coolname&gender=male
and You call it
$_GET["username"]; $_GET["gender"];
But in Zend Framework the url looks more like this:
hostname/user/aboutuser/username/wiwit/gender/man
And we can interpret it like this:
1. Controller = user
2. Action = aboutuser
3. username = Johnny
4. gender = man
So your controller should look like this:
<?php
class UserController extends Zend_Controller_Action
{
public function indexAction()
{
//some code here
}
public function aboutuserAction()
{
$request = $this->getRequest();
$this->view->assign('name', $request->getParam('username'));
$this->view->assign('gender', $request->getParam('gender'));
}
}
?>
And in your viewscript you should call it like this instead the old fasion way:
<?=$this->escape($this->name);?> <?=$this->escape($this->gender);?>
projects.php?action=list&team=Design&client=SomeClientName&status=All