CakePHP: GET Current Controller, Action and Parameters


Request Parameters


To get the current controller:

$controllerName = $this->request->getAttribute('controller');

To get the current action:

$acctionName= $this->request->getAttribute('action');

To get all passed arguments as a numerically indexed array:

http://localhost/calendars/view/recent/mark
$parameters = $this->request->getParam('pass');
Array
(
    [0] => recent
    [1] => mark
)

Query String Parameters


// URL is /posts/index?page=1&sort=title
$page = $this->request->getQuery('page');







Comments