php - CakePHP - Route configuration -


i working on cakephp , totally newbie php/cakephp. can please tell me wrong route configuration here?

router::connect(  '/news/:q/:page',  array('controller' => 'news',         'action' => 'ondemand',        'mode'=>'news',        'page'=>1),  array('pass'=>array('q','mode','page'),        'page' => '[\d]+')); 

when access page /news/123 or /news/123/1, tries find action '123' in news controller.

basically want if user types /news/android , want capture 'android' query , return results. if there may results, need support pagination i.e. url becomes /news/android/(2...n) .

you can this:

router::connect('/news/*', array('controller' => 'news', 'action' => 'ondemand')); 

have ondemand function declared as:

public function ondemand($subject, $page = null) 

when user requests /news/android or /news/android/2 cake call ondemand('android') or ondemand('android', '2'), respectively.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -