CodeIgniter HMVC How Define a SubModule User(User Logged)

530 Views Asked by At

I'm new in CodeIgniter and HMVC, and trying to make a web application The Structure I define is as follows

-Modules
   -User
      -Controllers
      -Views
      -Models
   -Orders
      -Controllers
      -Views
      -Models
   -Bills
      -Controllers
      -Views
      -Models
   -Payments
      -Controllers
      -Views
      -Models
     ...

The structure that I getting is

  http://localhost/site/Orders/.. or http://localhost/site/bills/..

That I want is a structure depending of the user logged, like this

  http://localhost/site/<currentuser>/Orders/
                or
  http://localhost/site/<iduser>/Orders/

How do I get this? I have read a lot of information and I dont know how to do it

1

There are 1 best solutions below

0
On

I think "http://localhost/site/" is the base URL of your website.


CodeIgniter routing pattern is as follows :

http://localhost/site/ControllerName/MethodName/Parameters/...


you want your URL call like this :
http://localhost/site/iduser/ControllerName/MethodName/Parameters/...


You can achieve this by using the bellow little hack in CodeIginter Core.


  1. Open system/core/router.php in your text editor.
  2. Go to Line number 264 .... function _validate_request($segments)
  3. Replace $segments[0] with $segments[1]

    OR

    Add this code at line 270

    $x=$segments; $a=1; for($i=0;$i<(count($segments)-1); $i++) { $segments[$i]=$x[$a]; $a++; }