dongnao6858 2016-08-17 20:19
浏览 58

CodeIgniter:在控制器中查找方法,如果没有,请查看默认控制器

I have the same app (made in CodeIgniter) running on the same server for three different clients.

The app is mostly the same, but each client has its own modifications (and its own subdomain), but right now any time I have to do a general modification I have to go through the app of all three clients and perform the modification.

What I want to have is:

The app deployed only once, and some kind of control there if you go to

client1.example.com/method1

The app looks for method1 in the controller client1.php, if method1 is found, it loads that instead, else, look for method1 in the controller default.php

That way, I can have general methods for all the clients load from the same source, and then specific controller for each client with their specific methods.

P.S. The methods are basically the same, but the different needs of the clients require to be able to make big modifications to each one.

Any help would be appreciated.


EDIT:

Ok, let me try to be more clear.

In wiredesignz Modular Extensions - HMVC, when you call index.php/welcome, it looks for it in the default controller. When you load a module and call index.php/welcome, it looks for it in the module directory first, if it's not found, will default to the default controller.

How can I achieve this without the module functionality?

  • 写回答

2条回答 默认 最新

  • duanfen7676 2016-08-17 21:18
    关注

    Ok Well... if i explain your question.

    assume i have URL's like this (home is my default controller )

    http://stackoverflow.com/home/method_1 # Exist in my controller 
    http://stackoverflow.com/home/method_2 # Exist in my controller 
    http://stackoverflow.com/home/method_3 # NOT in my controller  <--------- 
    http://stackoverflow.com/home/method_4 # Exist in my controller 
    

    In above links 3rd URL is not exist.

    With your question I got a Question. If URL is not there How User can access the link ??. No one know about your url unless you defined it. Users will not type URL in the browsers. Ok well will go ahead.


    So as better solution i got is, If page not exist we call it has 404 overriding. So you can use Codeigniter 404_override in routes.php

    http://stackoverflow.com/home/method_1 # Valid URL
    http://stackoverflow.com/home/method_2 # Valid URL
    http://stackoverflow.com/home/method_3 # 404 ERROR <---------
    http://stackoverflow.com/home/method_4 # Valid URL
    

    In application/config/routes.php

    $route['404_override'] = ''; # set this to your home controller
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统