CodeIgniter Forums
Loading a controller through an automatic condition - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Loading a controller through an automatic condition (/showthread.php?tid=66523)



Loading a controller through an automatic condition - Reiji - 10-31-2016

Hello everyone,

I have this problem, I have the same app that is being used by different entities, but I need to load different methods based on the user.

So, let's take this as an example:

User A is from California.
User B is from Minnesota.
User C is from Mexico.

User A have a specific way of displaying the user profile based on information that is available to him and only to him.

What I need is to have the three of them call the /users/profile/$id method, but CodeIgniter should check first if there exists a /a/users/profile/$1 before loading. It if exists, then load that, else load the default method.

Doing this on a regular condition (if else) is not an option because that would be a pain when there are over 70 users.

I know wireddesignz already does this with his modular expansion library, but I have no idea of how to achieve it.

Please help.

Thanks.


RE: Loading a controller through an automatic condition - InsiteFX - 10-31-2016

If you use an Auth system then you could link the users profile with the user information in the database.

user table:
user_id

When you create a new user then assign the user_id to the profile_id then you can add all the profile information that you need for that user at any time.

profile table
profile_id

Then you could store all the profile information using the user_id