controller - How to call multiple methods by URI segments in CodeIgniter -


i have issue codeigniter; have controller named site, , in controller there 2 methods: production , story.

production calls specific production via model creates production/slug.

what want achieve create following url:

site/production/slug/story  

how achieve that? slug changes, in story function want call story database using $this->uri->segment(3).

pass method name second parameter first method. example, if uri site/production/slug/story, pass story production method , necessary checks below:

class site extends ci_controller {      public function __construct()     {         parent::__construct()     }      public function story($text) {         echo $text;     }      public function production($slug = '', $callback = null)     {         // $slug          if (isset($callback) && method_exists(__class__, $callback)) {             $this->{$callback}($slug);         }     } } 

phpfiddle demo


Comments