Trying to understand Custom routes. I basically have no problem making route settings in application.ini but I want to do it another way. I checked the documentation but it aint clear as to where im supposed to place this code, for example:
Routes should go in your bootstrap file. They affect the entire application and are processed before the code even gets to the controller, so putting them in the controller would not work. Technically, you could also put routing info in index.php, I worked fo a company that did that, but it’s messy and less organized than putting it in the bootstrap file.
Now I have them set in my bootstrap.php and Im trying to access the variable but i am not getting anything: (Using version 1.11)
//BootStrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function initWithRoutes(){
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->addRouter(
'itemParam',
new Zend_Controller_Router_Route(
'/display/:item',
array('controller' => 'products', 'action' => 'display')
)
);
}
}
And this is my Controller:
//ProductsController.php
class ProductsController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function displayAction(){
if($this->getRequest()->getParam('item')){
$this->view->product = $this->_request()->getParam('item');
} else {
$this->view->product = 'nothing was passed';
}
}
}