![]() |
[SOLVED] URI Segments and default value for function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED] URI Segments and default value for function (/showthread.php?tid=44039) |
[SOLVED] URI Segments and default value for function - El Forum - 08-01-2011 [eluser]ravengerpl[/eluser] Hello! I have a question. I have controller "movie" with function "index()". Index() is loading model and view. Code: public function index() I also have function "sort($sort_key, $sort_type)" in my "movie" controller (it also loading model and view). Code: public function sort($sort_key, $sort_type) getall() and sort_and_get($sort_key, $sort_type) are getting all rows from one table (but sort_and_get also sort by key (column name) and type (asc, desc). Is it possible to merge them and set default values for variables sort_type and sort_key? I would like to have something like this: - when I'm typing example.com/movie/index.html I would like to load page with full list of movies from database (sorted by title, asc - this would be default) - when I'm typing example.com/movie/index/$sort_key/$sort_type I would like to load page with full list of movies from database sorted by key and type from URI I was trying something like this but that didn't work. Code: public function index($sort_key, $sort_type) Or should I use routing and redirect from example.com/movie/sort to index? [SOLVED] URI Segments and default value for function - El Forum - 08-01-2011 [eluser]ravengerpl[/eluser] OK, solved, found my answer here http://ellislab.com/forums/viewthread/132040/ My index() now looks like this: Code: public function index($sort_key = '', $sort_type = '') |