CakePHP: GET Current Controller, Action and Parameters



We will have the following url:

                      http://sherwinrobles.blogspot.com/users/view/1/2/3

To get the current controller:

                     echo $this->params['controller'];
Output:
        users


To get the current action:

                      echo $this->action;
Output:
        view


To get the first parameter:

                     echo $this->params['pass'][0];
Output:
        1

To get the second parameter:

                      echo $this->params['pass'][1];
Output:
        2

To get the first parameter:

                      echo $this->params['pass'][2];
Output:
        3

and so on...







Post a Comment

Popular posts from this blog

CakeAdminLTE is based on AdminLTE Theme for CakePHP 2.4+

CakePHP: COUNT data and GROUP BY date

CakePHP: Calling function from other controller