A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearZend Framework: How to get default param? - page 1
User InfoPosts
Zend Framework: How to get default param?#1
How do I get the (default( param if not specified?

Consider the following:

http://localhost/controller/action/id/123


In my controller, I can get the value of (id( using

$request = $this->getRequest();
$id = $request->getParam((id();


If the URL is

http://localhost/controller/action/456


how do I get the value of 456?
What is the (param( name?

posted date: 2009-04-16 02:33:00


Re: Zend Framework: How to get default param?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-16 02:33:01


Re: Zend Framework: How to get default param?#3
By default ZF URL have to follow pattern: /controller/action/param1Name/param1Val/param2Name/param2Val ...You should use router. For example in bootstrap.php:$frontController = Zend_Controller_Front::getInstance(); //^^^this line should be already there$router = $frontController->getRouter();$route = new Zend_Controller_Router_Route( (yourController/yourAction/:id(, array( (id( => 1, //default value (controller( => (yourController(, (action( => (yourAction( ), array((id( => (\d+());$router->addRoute((yourController(, $route);

posted date: 2009-04-16 02:37:00


Re: Zend Framework: How to get default param?#4
try to add this route to router:$route = new Zend_Controller_Router_Route_Regex( (my_controller/my_action/(\d+)(, array( (controller( => (my_controller(, (action( => (my_action( ));$router->addRoute((my_route(, $route);

posted date: 2009-04-16 02:49:00


Re: Zend Framework: How to get default param?#5
Where exactly should I add this router? In the doc says in Controller. Is it controllers/myController.php? or in bootstrap.php file? TQ!

posted date: 2009-04-16 03:18:00


Re: Zend Framework: How to get default param?#6
Where exactly should I add this router? In the doc says in Controller. Is it controllers/myController.php?

posted date: 2009-04-16 05:12:00


Re: Zend Framework: How to get default param?#7
Just want to share.The above router setting must be used with the $frontController.And be sure put it before the controller dispatches.<..above router code goes here...>// Dispatch the request using the front controller. $frontController->dispatch ();Hope don(t waste time like myself. ;-)

posted date: 2009-04-16 06:52:00


Re: Zend Framework: How to get default param?#8
Thank you. Just to share that I need to put all this before dispatching the front controller. <above code goes here> // Dispatch the request using the front controller. $frontController->dispatch ();

posted date: 2009-04-16 06:55:00


Re: Zend Framework: How to get default param?#9
And what if when i want to use more parameters like localhost/controller/action/… ?

posted date: 2009-08-12 01:42:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.