[英]hmvc codeigniter routes modules controller function
我有来自https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc的 hmvc结构
模块content ,创建控制器news_event ,并让函数视图详细显示这样的结构
在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
如果您使用模块文件夹中的路由文件,则路由名称必须以模块名称开头。
modules / content / config / routes.php
$route['default_controller'] = 'content';
$route['content/'] = '';
您可以在常规路由文件中添加路由
application / config / routes.php
$route['news_event'] = 'content/content/news_event';
hmvc背后的想法是不通过路由方法调用模块,而是在系统本身(视图或控制器)内调用模块
Modules::run('module/controller/method', $args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.