应用插件 版主:官方插件技术组
如何让$ci 能在任何页面使用或者后台models里使用
类型:迅睿CMS 更新时间:2025-02-26 16:17:59 生成静态

如何让$ci 能在任何页面使用或者后台models里使用

以下是 CHTML 插件里的,我发现这个$ci 需要在  模块的 HTML.PHP 文件里传递

如果用在插件里,$ci->content_model->_Show 会报错,就找不到这个方法

如果让它在任意地方用起来呢?

        $id = 41;
        $dirname = 'news';

        ob_start();
        // 修复前缀
        $ci->content_model->_init($dirname,SITE_ID);
        // 生成静态路由纠正
        \Phpcmf\Service::L('router')->class = 'show';
        \Phpcmf\Service::L('router')->method = 'index';
        \Phpcmf\Service::V()->init('pc');
        \Phpcmf\Service::V()->module($ci->module['share'] ? 'share' : $ci->module['dirname']);
        \Phpcmf\Service::V()->assign('my_php_url', SITE_URL.'index.php?not301=2&'.($ci->module['share'] ? '' : 's='.$ci->module['dirname'].'&').'c=show&id='.$id);
        $data = $ci->content_model->_Show($id);
        $html = ob_get_clean();




应用版权:自己研发的应用插件
应用名称:-
回帖
  • GoWorkRoom
    #1楼    GoWorkRoom
    2025-02-26 15:07:58
    Chrome 0
    $ci = XR_C();
  • 小黄人 18html
    #2楼    小黄人 18html
    2025-02-26 15:12:19
    Chrome 0
    GoWorkRoom 不行的,如果这么简单,我已经写完了!这个我写过了
  • 天天向上
    #3楼    天天向上
    2025-02-26 15:28:46
    Chrome 0
    content类里面没有_Show啊,你是不是掉错了位置了
    满意答案
  • 小黄人 18html
    #4楼    小黄人 18html
    2025-02-26 15:30:14
    Chrome 0
    天天向上 所以我强调了,静态生成插件!这个问题,估计要官方来解决
  • 小黄人 18html
    #5楼    小黄人 18html
    2025-02-26 15:41:15
    Chrome 0
    天天向上 嗯是的。我自己改了之后复制的,复制错了原代码应该是
            // 开启ob函数
            ob_start();
            // 修复前缀
            $ci->content_model->_init($ci->module['dirname'], SITE_ID);
            // 生成静态路由纠正
            \Phpcmf\Service::L('router')->class = 'show';
            \Phpcmf\Service::L('router')->method = 'index';
            \Phpcmf\Service::V()->init('pc');
            \Phpcmf\Service::V()->module($ci->module['share'] ? 'share' : $ci->module['dirname']);
            \Phpcmf\Service::V()->assign('my_php_url', SITE_URL.'index.php?not301=2&'.($ci->module['share'] ? '' : 's='.$ci->module['dirname'].'&').'c=show&id='.$id);
            $data = $ci->_Show($id, '', $page);
    
            $html = ob_get_clean();
  • 小黄人 18html
    #6楼    小黄人 18html
    2025-02-26 16:17:59
    Chrome 0
    @天天向上:搞定,大佬出手就知有没有,找官方搞了下