简体   繁体   English

hmvc codeigniter路由模块控制器功能

[英]hmvc codeigniter routes modules controller function

i have hmvc structure from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc 我有来自https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc的 hmvc结构

modules content , create controller news_event , and for function view to detail view the structure like this 模块content ,创建控制器news_event ,并让函数视图详细显示这样的结构

  • modules 模组
    • ... ...
    • ... ...
    • content 内容
      • controllers 控制器
        • ... ...
        • news_event.php news_event.php

in news_event.php news_event.php中

i having 3 function,index, view and pages 我有3个功能,索引,视图和页面

 function index() { $this->pages(); }

 function pages($_pages = 1){ ... }

 function view($_id_uri = false){ ... }

i had success make 我成功了

http://example.com/ci_hmvc/content/news_event/ http://example.com/ci_hmvc/content/news_event/

become 成为

http://example.com/ci_hmvc/news_event/ http://example.com/ci_hmvc/news_event/

but its error when its load next view 但是在加载下一个视图时出现错误

http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here

i got error 404, but if i call with this url, success 我收到错误404,但如果我使用此网址进行调用,则成功

http://example.com/ci_hmvc/content/news_event/view/my-var-uri-friendly-here http://example.com/ci_hmvc/content/news_event/view/my-var-uri-friendly-here

my routing code is 我的路由代码是

 $route['news_event'] = 'content/news_event';
 $route['news_event/(:any)'] = 'content/news_event/view/$1';

how routes, if i want to access with 如何路线,如果我想访问

http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here

or this 或这个

http://example.com/ci_hmvc/news_event/my-var-uri-friendly-here http://example.com/ci_hmvc/news_event/my-var-uri-friendly-here

If your using a route file from within the module folder, the route name must start with the module name. 如果您使用模块文件夹中的路由文件,则路由名称必须以模块名称开头。

modules/content/config/routes.php modules / content / config / routes.php

$route['default_controller'] = 'content';

$route['content/'] = '';

You could add the route in the normal routing file 您可以在常规路由文件中添加路由

application/config/routes.php application / config / routes.php

$route['news_event'] = 'content/content/news_event';

The idea behind hmvc is to not call a module via the routing method, but rather call the module within the system itself(view or controller) hmvc背后的想法是通过路由方法调用模块,而是在系统本身(视图或控制器)内调用模块

Modules::run('module/controller/method', $args);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM