dongshao2967 2014-12-14 16:49
浏览 42

CodeIgniter HMVC如何定义子模块用户(用户记录)

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条回答 默认 最新

  • doufeinai6081 2014-12-17 09:38
    关注

    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++; }

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改