织梦自定义php页面调用include引用模板
温馨提示:DedeCMS用户请及时前往织梦官网处理官方版权事宜。
我们有时候需要在php文件中引用模板,举个栗子,在会员中心的模板文件中,用include是无法直接引用前台的页面文件,如果我们要饮用,怎么操作呢?
首先打开/include/common.func.php文件,加入一个函数
function pasterTempletDiy($path) { require_once(DEDEINC."/arc.partview.class.php"); global $cfg_basedir,$cfg_templets_dir; $tmpfile = $cfg_basedir.$cfg_templets_dir."/".$path;//模版文件的路径 $dtp = new PartView(); $dtp->SetTemplet($tmpfile); $dtp->Display(); }
自定义demo.php文件,内容如下:
<?php require_once("../../include/common.inc.php"); ?>
读取公共文件,就使用:
<?php pasterTempletDiy("default/head.htm");?>
本文属原创,转载请注明原文:http://www.zhimatong.com/jiaocheng/458.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
内容有用