hmvc codeigniter路由模块控制器功能

时间:2013-05-12 13:35:19

标签: php codeigniter

我有来自https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

的hmvc结构

模块内容,创建控制器 news_event ,功能查看到详细视图 像这样的结构

  • 模块
    • ...
    • ...
    • 内容
      • 控制器
        • ...
        • news_event.php
news_event.php

中的

我有3个功能,索引,视图和页面

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

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

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

我成功了

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

成为

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

但在加载下一个视图时出现错误

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

我收到错误404,但是如果我使用此网址调用,则成功

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

我的路由代码是

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

路径如何,如果我想用

访问

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

或者

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

1 个答案:

答案 0 :(得分:1)

如果您使用模块文件夹中的路径文件,则路径名称必须以模块名称开头。

<强>模块/内容/配置/ routes.php文件

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

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

您可以在正常路由文件中添加路由

<强>应用/配置/ routes.php文件

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

hmvc背后的想法是通过路由方法调用模块,而是在系统内部调用模块(视图或控制器)

Modules::run('module/controller/method', $args);
相关问题