php - Cakephp Passed arguments -
hello, code not working in cakephp framework , showing error message.
url:
http://domainname.com/about/param1/param2 code:
class aboutcontroller extends appcontroller { public $name = 'about'; public $helpers = array('html'); public function index($arg1, $arg2) { print_r($this->request->params['pass']); $this->set('title_for_layout','sarasavi bookshop - sarasavi bookshop'); $this->set('nameforfiles','about'); } } error message:
missing method in aboutcontroller error: action param1 not defined in controller aboutcontroller error: create aboutcontroller::param1() in file: app\controller\aboutcontroller.php. <?php class aboutcontroller extends appcontroller { public function param1() { } } notice: if want customize error message, create app\view\errors\missing_action.ctp after creating function param1 can param2, need param1 , param2 both, in index function without create action.
please help me, thanks
your original code work if went http://domainname.com/about/index/param1/param2
if don't want index in url, assume don't, need define route.
add routes:
router::connect( '/about/*', array('controller' => 'about', 'action' => 'index') ); to automatically route requests don't specify action have params go index action. need add together route new about actions stop requests them going index default though.
php cakephp routing url-routing
No comments:
Post a Comment