callum.bennett
callum.bennett

Reputation: 686

codeigniter extra url segments

I am making a site for a client and decided i would use code igniter.

The site essentially has two backends, one for designers, and one for a sales team. So after logging in, the user will be redirected to either

The sales team for example can view orders, containers, products, therefore i need a controller for each of these.

The sales need to be able to view, edit, delete certain orders...

Basically my problem is i dont have enough url segments to play with.

My thoughts on solving my problem

I appreciate any advice, I just dont want to get 3 weeks into the project and realise i started wrong from the beginning!

Upvotes: 0

Views: 332

Answers (3)

ramono
ramono

Reputation: 462

Use folders.

If you make a subfolder in /application/ called sales you can put different controllers in there:

/application/
    /sales/
      orders.php /* Controller */
    /design/

Then in orders.php you will put your vieworders($id) method and so on, and you will be able to acces it with domain.com/sales/orders/vieworders/id.

You can also make subfolders in the /models/ and /views/ to organize your files.

Now, Access Control is something apart and it depends more in the auth system you are using.

Upvotes: 2

user827080
user827080

Reputation:

Seems like you should have a look into the routing class. Might be a dirty solution but rerouting the sales/(:any) to something like sales_$1 would mean you'd make controllers with names like sales_orders. Same for the design part.

(FYI: $routing['sales/(:any)'] = 'sales_$1'; should do the trick; see application/config/routing.php).

Upvotes: 0

Herr
Herr

Reputation: 2735

Give the user/designer a privilege, a column in the user table for example, check the permission of the user at the beginning of the function, then prevent or execute it.

This would be the exact way i would do it.

Upvotes: 0

Related Questions