Onex ecstore中(page、display、fetch、singlepage)的区别

1.Page

显示页面,如果page配合target=_blank使用时,显示的页面包含在框架里面,显示在后台的自定义列表中

当target=dialog,则显示的是弹出界面(这时候display和page是一样的效果)

eg:1

'href'=>'index.php?app=b2c&ctl=admin_goods_editor&act=add',
'target'=>'_blank'),
$this->page('admin/goods/detail/frame.html')

eg:2

'href'=>'index.php?app=b2c&ctl=admin_member&act=add_page','target'=>'dialog::{title:\''.app::get('b2c')->_('添加会员').'\',width:460,height:460}'),
...
$this->page('admin/member/new.html');

2.Display

display和base_render中的display方法一样

display配合target=dialog使用时,显示的页面为弹出层,但不能配_blank合使用。

3.Fetch

fetch和display方法一样,唯一的不同就是

fetch include的模板时不需要执行pre_display过滤,主模板会最终执行一次。(下边将贴出display和fetch的方法)

function fetch($tmpl_file,$app_id=null,$is_theme=false){
        return $this->display($tmpl_file, $app_id, true, $is_theme);
 }
   function display($tmpl_file, $app_id=null, $fetch=false, $is_theme=false){
        array_unshift($this->_files,$tmpl_file);
        $this->_vars = $this->pagedata;

        if($p = strpos($tmpl_file,':')){
            $object = kernel::service('tpl_source.'.substr($tmpl_file,0,$p));
            if($object){
                $tmpl_file_path = substr($tmpl_file,$p+1);
                $last_modified = $object->last_modified($tmpl_file_path);
            }
        }else{
            if(defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file)){
                 $tmpl_file = CUSTOM_CORE_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file;    
            }else{
                 if (!$is_theme)
                    $tmpl_file = realpath(APP_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file);
                 else
                    $tmpl_file = realpath(THEME_DIR.'/'.$tmpl_file);
            }
            $last_modified = filemtime($tmpl_file);
        }

        if(!$last_modified){
            //无文件
        }

        $this->tmpl_cachekey('__temp_lang', kernel::get_lang());  //设置模版所属语言包
        $this->tmpl_cachekey('__temp_app_id', $app_id?$app_id:$this->app->app_id);
        $compile_id = $this->compile_id($tmpl_file);

        #if($this->force_compile || base_kvstore::instance('cache/template')->fetch($compile_id, $compile_code, $last_modified) === false){
        if($this->force_compile || !cachemgr::get($compile_id.$last_modified, $compile_code)){
            if($object){
                $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
            }else{
                $compile_code = $this->_compiler()->compile_file($tmpl_file);
            }
            if($compile_code!==false){
                #base_kvstore::instance('cache/template')->store($compile_id,$compile_code);
                cachemgr::co_start();
                cachemgr::set($compile_id.$last_modified, $compile_code, cachemgr::co_end());
            }
        }

        ob_start();
        eval('?>'.$compile_code);
        $content = ob_get_contents();
        ob_end_clean();
        array_shift($this->_files);

        $this->pre_display($content);
//注意这里是关键哦,如果$fetch为真,就返回页面也就意味着页面include一次就终止了。
//如果为假,将会一直进行输出
        if($fetch === true){
            return $content;
        }else{
            echo $content;
        }
    }

4.Singlepage

用法:显示页面,默认配合target=_blank使用时,显示的页面不包含框架的其他页面,只是本身页面,记住哦。只是页面本身不含任何框架!!

'href'=>'index.php?app=b2c&ctl=admin_goods_editor&act=add',
'target'=>'_blank'),
...
$this->singlepage('admin/goods/detail/frame.html');