arthurwu 发表于 2011-9-7 12:00:31

最近看了下 DiliCMS 实在有几个地方没看懂````

本帖最后由 arthurwu 于 2011-9-7 12:30 编辑

第一个就是:core/Dili_Controller.php 这个文件里面的,
                function _theme_switcher($button = 'on' , $theme = 'default' ,$path = 'templates/'){
                        if($button == 'on')
                        {
                              $this->load->_ci_view_path = FCPATH.$path.$theme.'/';
                        }
                }
这个是选择模板的,但是这个 $this->load->_ci_view_path,和function _theme_switcher 在codeigniter里面默认就是有的吗,还是自己写的。

还有一个地方就是在类似:后台设置文件controllers/admin/setting.php 里面
                function site()
                {
                        $data['site'] = $this->db->get('dili_site_settings')->row();
                        $this->_template('settings_site',$data);
                }
               
                function _site_post()
                {
                        $this->db->update('dili_site_settings',$this->input->post());
                        update_cache('site');
                        $this->_message("更新成功",'setting/site',true,($this->input->get('tab') ? '?tab='.$this->input->get('tab') : '' ));
                }
这个一提交就是调用_site_post这个方法,是怎么来着 ,在html中得form表单action类似是这样的"/index.php/admin/setting/site?tab=site_basic"提交后怎么就是到_site_post()这个方法呢?

jeongee 发表于 2011-9-7 13:48:31

本帖最后由 jeongee 于 2011-9-7 13:57 编辑

1.
$this->load->_ci_view_path就是ci的core/Loader.php这个类,你可以去看看,那个函数是自己写的
2.
我写的钩子,实现的这个,你可以看application/hooks/MethodHook.php

arthurwu 发表于 2011-9-7 15:30:03

多谢 :lol

arthurwu 发表于 2011-9-9 15:43:00

jeongee 发表于 2011-9-7 13:48 static/image/common/back.gif
1.
$this->load->_ci_view_path就是ci的core/Loader.php这个类,你可以去看看,那个函数是自己写的
2.


又要麻烦你了,我像你这样设置之后 $this->load->_ci_view_path 之后可是为什么不能想你那样把 后台 admincp 模板拿出来放在外面 ,而是 还是要把视图放在view 下面才行呢?

jeongee 发表于 2011-9-9 15:54:37

arthurwu 发表于 2011-9-9 15:43 static/image/common/back.gif
又要麻烦你了,我像你这样设置之后 $this->load->_ci_view_path 之后可是为什么不能想你那样把 后台 admin ...

那还是用的不对吧

arthurwu 发表于 2011-9-9 16:03:17

jeongee 发表于 2011-9-9 15:54 static/image/common/back.gif
那还是用的不对吧

应该是对的吧 , 我在页面上都直接输出路劲看了下 ,而且 我是直接复制你的

jeongee 发表于 2011-9-9 16:05:02

arthurwu 发表于 2011-9-9 16:03 static/image/common/back.gif
应该是对的吧 , 我在页面上都直接输出路劲看了下 ,而且 我是直接复制你的...

那我就不是很清楚啦
不过这样是可以随意定制view的位置的

arthurwu 发表于 2011-9-9 16:06:23

直接输出的路劲是 :
D:\www\www\newshop\smyblog\ctr/default/

这个是应用程序的路劲:
D:\www\www\newshop\smyblog\application
应该没有错把

我是最新版本的,2.0.3
难道是还有别的地方需要设置吗

arthurwu 发表于 2011-9-9 16:37:13

jeongee 发表于 2011-9-9 16:05 static/image/common/back.gif
那我就不是很清楚啦
不过这样是可以随意定制view的位置的

知道原因了,是版本的问题,官方重写了core/Loader.php 这个类,

把这个类的         protected$_ci_view_paths                = array();改成
                      public           $_ci_view_paths                = array();
方法改下就可以了:
                function _theme_switcher($button = 'on' , $theme = 'default' ,$path = 'templates/'){
                        if($button == 'on'){
                                $this->load->_ci_view_paths = array(FCPATH.$path.$theme.'/'        => TRUE);
                        }
                }       
呵呵 ,不知道还有什么更好的办法

jeongee 发表于 2011-9-9 16:40:28

arthurwu 发表于 2011-9-9 16:37 static/image/common/back.gif
知道原因了,是版本的问题,官方重写了core/Loader.php 这个类,

把这个类的         protected$_ci_view_paths       ...

原来是这样,我没升级到2.0.3所以不知道,呵呵
页: [1] 2
查看完整版本: 最近看了下 DiliCMS 实在有几个地方没看懂````