Welcome Guest, Not a member yet? Register   Sign In
How to pass argument to index(arg='') ?
#6

(06-21-2016, 06:40 AM)zenepay Wrote:
(06-21-2016, 05:54 AM)dmyers Wrote: If you want /home and /home/{{id}} you can always write a route in the application/config/routes.php file.

This is covered here http://www.codeigniter.com/user_guide/ge...ght=routes

So you could add for example:

$route['home/(:num)'] = 'home/index/$1';

DMyers

This looks like we have to do for all controller classes if all controller classes have index($id='')

Depending on the URI structure you are trying to create/recreate (ie. SEO reason, Business Reason, etc...) and because CodeIgniter uses the first 2 URI segments as the controller and methods (if you aren't using folders http://www.codeigniter.com/user_guide/ge...irectories). Then you will need to add the routes.

This is covered here: http://www.codeigniter.com/user_guide/ge...ur-methods

Assuming your URI structure isn't for any specific reason then why couldn't you use something like:

/people (of course default's to /people/index - list view)
/people/new (new record)
/people/edit/1 (edit record 1)
/people/delete/1 (delete record 1)
/people/view/1 (view record 1)
/people/details/1 (view record 1)

In the example above the Controller would be something like this:

class People extends CI_Controller {

public function index() {...}
public function new() {...}
public function edit($id=null) {...}
public function delete($id=null) {...}
public function view($id=null) {...}
public function details($id=null) {...}

}
Reply


Messages In This Thread
RE: How to pass argument to index(arg='') ? - by dmyers - 06-21-2016, 08:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB