views:

50

answers:

2

how to access this paramvalue in controller..?

$router->map('Company', 'Company', array( 
 'controller' => 'companies', 
 'action' => 'add', 
 'paramkey' => 'paramvalue', 
 'anotherparam' => 'anothervalue')); 

Plz help me

A: 

Try

$this->getRequest()->getParam('paramkey');
heximal
where shall i declare getrequest and getparam???
ekta
insinde controller methods
heximal
can u please help me with the defination of method?
ekta
A: 

get one param:

$this->getRequest()->getParam('paramkey'[, 'default value']);

get all params:

$this->getRequest()->getAllParams();

or

$this->_getParam('paramkey'[, 'default value']);
$this->_getAllParams();

I`m using Zend Framework so method described in Zend_Action_Contoller:

/**
 * Gets a parameter from the {@link $_request Request object}.  If the
 * parameter does not exist, NULL will be returned.
 *
 * If the parameter does not exist and $default is set, then
 * $default will be returned instead of NULL.
 *
 * @param string $paramName
 * @param mixed $default
 * @return mixed
 */
protected function _getParam($paramName, $default = null)

if you are using CacePHP you can try

$this->params['paramkey'];

but I`m not sure it will work

Vytautas
it is showing getParam unknown method
ekta
I have just tested and everything working just fine for me maybe you using wrong or not in controller?
Vytautas
do u have zend installed?? i mean i guess it should be defined in zend. but the s/w in which i've to do the customization has its own framework but its similar to cakephp...so let me knw where shall i find getParam???
ekta
I`m using Zend Framework so method described in Zend_Action_Contoller: /** * Gets a parameter from the {@link $_request Request object}. If the * parameter does not exist, NULL will be returned. * * If the parameter does not exist and $default is set, then * $default will be returned instead of NULL. * * @param string $paramName * @param mixed $default * @return mixed */ protected function _getParam($paramName, $default = null)if you are using phpCake you can try
Vytautas
though my framework is not cakephp...i tried $this->param[] and its not showing error.but not comparing the value though.
ekta
$flag = $this->params['is_owner']; if(flag=='1')
ekta
In mapping i've kept this... $router->map('Owner', 'Owner/true','null', array('controller' => 'companies', 'action' => 'index','is_owner'=> '1')); $router->map('Client', 'Client/false','null', array('controller' => 'companies', 'action' => 'index','is_owner'=>'')); and in controller..... $flag = $this->params['is_owner']; if(flag=='1'){action;}else{action} Please help me...m stuck here since 20 days
ekta
maybe sessions for you is better solution :D or you can try just $_GET['is_owner'] and hope it works. I don't know your framework but you should get this param like other GET or POST parameters if you know how.
Vytautas
what does defaults mean?? i mean ... $router->map('Owner', 'Owner/true','null', array('controller' => 'companies', 'action' => 'index','is_owner'=> '1')); in this the array is stored in defaults..does it pass it with get, post??
ekta
yes it should do that. but you can test that in your framework whatever it is :) good luck
Vytautas