duanfengdian7014 2013-05-12 13:35
浏览 52

hmvc codeigniter路由模块控制器功能

i have hmvc structure from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

modules content, create controller news_event, and for function view to detail view the structure like this

  • modules
    • ...
    • ...
    • content
      • controllers
        • ...
        • news_event.php

in news_event.php

i having 3 function,index, view and pages

 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/

become

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

i got error 404, but if i call with this url, success

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

or this

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

  • 写回答

1条回答 默认 最新

  • dongyinzhi4689 2013-05-12 18:55
    关注

    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

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

    You could add the route in the normal routing file

    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)

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

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用