Welcome Guest, Not a member yet? Register   Sign In
[solved] Tricky Folder Layout
#4

[eluser]xwero[/eluser]
Lets say you have not a lot of code and you put all the things in one controller
Code:
class Accounts extends Controller
{
    function index()
    {
       switch($this->uri->segment(2))
       {
          case 'delete': /* code */ break;
          // ...
          default: /* no extra segments */ break;
       }
    }

    function orders() // same structure for images
    {
       switch($this->uri->segment(3))
       {
          case 'delete': /* code */ break;
          // ...
          default: /* no extra segments */ break;
       }
    }
}
Then you can set up your routing as follows
Code:
$route['account/(delete|other|actions)(.*)'] = 'account/index/$1$2';
And that is the only routing you need because the account/orders will be routed to the correct method by default.

If you want to split the controllers to have smaller files you could go for following file structure

actions/actions.php : the index function in the controller above
actions/orders.php
actions/images.php

And in the routing this will have following result
Code:
$route['account'] = 'account/account';
$route['account/(delete|other|actions)(.*)'] = 'account/account/$1$2';
The cases in the switch become methods.


Messages In This Thread
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 04:52 AM
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 05:03 AM
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 05:17 AM
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 05:33 AM
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 06:15 AM
[solved] Tricky Folder Layout - by El Forum - 01-14-2009, 06:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB