教程讲解dedecms动态编译式模版引擎
2016-03-21 10:59
204 查看
教程教程讲解dedecms动态编译式模版引擎,请参照DedeCMS论坛天涯版主的二次开发视频,否则各别地方可能会报错。
视频传送门:http://help.dedecms.com/video/template/2011/0720/320.html
转载请注明:http://blog.sina.com.cn/u/1756719835
设定文件名为code.php,以下为里面内容
<?php
require_once(dirname(__FILE__)."/include/common.inc.php");
require_once(dirname(__FILE__)."/include/channelunit.func.php");
require_once(dirname(__FILE__)."/include/dedetag.class.php");
if($action ==
'tpl'){
require_once(dirname(__FILE__)."/include/dedetemplate.class.php");
//设定模版目录,下面可以直接填入文件名
$tpl
= new DedeTemplate(dirname(__FILE__));
//载入模版文件
$tpl
->LoadTemplate('code.tpl.htm');
//---------------华丽丽的分割线------------
$title="我的DedeCMS网站";
$tpl
->SetVar("title",$title);
$arr=array(
name
=> 'DedeCMS',
company => 'DesDev
INC'
);
$tpl ->SetVar("arr",$arr);
$obj
= new stdclass;
$obj ->name='tianya';
$obj
->email='tianya@163.com';
$obj ->now
=time();
$tpl ->SetVar("obj",$obj);
$isshow =
true;
$tpl
->SetVar("isshow",$isshow);
//显示页面
//$tpl
->Display();
//生成htm文件
$tpl
->SaveTo('code.htm');
exit();
}
?>
设定文件名code.tpl.htm,以下为其内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
{dede:var name='title'/}<br />
名字:{dede:var.arr.name/}<br />
公司:{dede:var.arr.company/}<br
/>
{dede:cfg.webname/}<br />
{dede:global.cfg_webname/}<br />
{dede:object.obj->name/}<br />
{dede:object.obj->email/}<br
/>
{dede:object.obj->now function="MyDate('Y-m',@me)"/}<br
/>
遍历数组:<br />
{dede:array.arr
comment='这里是注释的位置'}
{dede:key/} = {dede:value/}<br
/>
{/dede:array}
{dede:php}
echo "hello word";
{/dede:php}
<br
/>
{dede:if
var.isshow}
需要显示
{else}
不需要显示
{/dede:if}
<br
/>
{dede:tianya name='hello' rstype='string'/}
<br
/>
{dede:memberlist}
{dede:field.mid/}-{dede:field.uname/}<br
/>
{/dede:memberlist}
{dede:include
filename='footer.tpl.htm'/}
</body>
</html>
设定文件名footer.tpl.htm其内容为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
<br
/>-----------------------------------------------------------<br />
CMS和网站运营 is Powered by WordPress. Keso theme by dupola
</body>
</html>,请参照DedeCMS论坛天涯版主的二次开发视频,否则各别地方可能会报错。
视频传送门:http://help.dedecms.com/video/template/2011/0720/320.html
转载请注明:http://blog.sina.com.cn/u/1756719835
设定文件名为code.php,以下为里面内容
<?php
require_once(dirname(__FILE__)."/include/common.inc.php");
require_once(dirname(__FILE__)."/include/channelunit.func.php");
require_once(dirname(__FILE__)."/include/dedetag.class.php");
if($action ==
'tpl'){
require_once(dirname(__FILE__)."/include/dedetemplate.class.php");
//设定模版目录,下面可以直接填入文件名
$tpl
= new DedeTemplate(dirname(__FILE__));
//载入模版文件
$tpl
->LoadTemplate('code.tpl.htm');
//---------------华丽丽的分割线------------
$title="我的DedeCMS网站";
$tpl
->SetVar("title",$title);
$arr=array(
name
=> 'DedeCMS',
company => 'DesDev
INC'
);
$tpl ->SetVar("arr",$arr);
$obj
= new stdclass;
$obj ->name='tianya';
$obj
->email='tianya@163.com';
$obj ->now
=time();
$tpl ->SetVar("obj",$obj);
$isshow =
true;
$tpl
->SetVar("isshow",$isshow);
//显示页面
//$tpl
->Display();
//生成htm文件
$tpl
->SaveTo('code.htm');
exit();
}
?>
设定文件名code.tpl.htm,以下为其内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
{dede:var name='title'/}<br />
名字:{dede:var.arr.name/}<br />
公司:{dede:var.arr.company/}<br
/>
{dede:cfg.webname/}<br />
{dede:global.cfg_webname/}<br />
{dede:object.obj->name/}<br />
{dede:object.obj->email/}<br
/>
{dede:object.obj->now function="MyDate('Y-m',@me)"/}<br
/>
遍历数组:<br />
{dede:array.arr
comment='这里是注释的位置'}
{dede:key/} = {dede:value/}<br
/>
{/dede:array}
{dede:php}
echo "hello word";
{/dede:php}
<br
/>
{dede:if
var.isshow}
需要显示
{else}
不需要显示
{/dede:if}
<br
/>
{dede:tianya name='hello' rstype='string'/}
<br
/>
{dede:memberlist}
{dede:field.mid/}-{dede:field.uname/}<br
/>
{/dede:memberlist}
{dede:include
filename='footer.tpl.htm'/}
</body>
</html>
设定文件名footer.tpl.htm其内容为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
<br
/>-----------------------------------------------------------<br />
CMS和网站运营 is Powered by WordPress. Keso theme by dupola
</body>
</html>
视频传送门:http://help.dedecms.com/video/template/2011/0720/320.html
转载请注明:http://blog.sina.com.cn/u/1756719835
设定文件名为code.php,以下为里面内容
<?php
require_once(dirname(__FILE__)."/include/common.inc.php");
require_once(dirname(__FILE__)."/include/channelunit.func.php");
require_once(dirname(__FILE__)."/include/dedetag.class.php");
if($action ==
'tpl'){
require_once(dirname(__FILE__)."/include/dedetemplate.class.php");
//设定模版目录,下面可以直接填入文件名
$tpl
= new DedeTemplate(dirname(__FILE__));
//载入模版文件
$tpl
->LoadTemplate('code.tpl.htm');
//---------------华丽丽的分割线------------
$title="我的DedeCMS网站";
$tpl
->SetVar("title",$title);
$arr=array(
name
=> 'DedeCMS',
company => 'DesDev
INC'
);
$tpl ->SetVar("arr",$arr);
$obj
= new stdclass;
$obj ->name='tianya';
$obj
->email='tianya@163.com';
$obj ->now
=time();
$tpl ->SetVar("obj",$obj);
$isshow =
true;
$tpl
->SetVar("isshow",$isshow);
//显示页面
//$tpl
->Display();
//生成htm文件
$tpl
->SaveTo('code.htm');
exit();
}
?>
设定文件名code.tpl.htm,以下为其内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
{dede:var name='title'/}<br />
名字:{dede:var.arr.name/}<br />
公司:{dede:var.arr.company/}<br
/>
{dede:cfg.webname/}<br />
{dede:global.cfg_webname/}<br />
{dede:object.obj->name/}<br />
{dede:object.obj->email/}<br
/>
{dede:object.obj->now function="MyDate('Y-m',@me)"/}<br
/>
遍历数组:<br />
{dede:array.arr
comment='这里是注释的位置'}
{dede:key/} = {dede:value/}<br
/>
{/dede:array}
{dede:php}
echo "hello word";
{/dede:php}
<br
/>
{dede:if
var.isshow}
需要显示
{else}
不需要显示
{/dede:if}
<br
/>
{dede:tianya name='hello' rstype='string'/}
<br
/>
{dede:memberlist}
{dede:field.mid/}-{dede:field.uname/}<br
/>
{/dede:memberlist}
{dede:include
filename='footer.tpl.htm'/}
</body>
</html>
设定文件名footer.tpl.htm其内容为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
<br
/>-----------------------------------------------------------<br />
CMS和网站运营 is Powered by WordPress. Keso theme by dupola
</body>
</html>,请参照DedeCMS论坛天涯版主的二次开发视频,否则各别地方可能会报错。
视频传送门:http://help.dedecms.com/video/template/2011/0720/320.html
转载请注明:http://blog.sina.com.cn/u/1756719835
设定文件名为code.php,以下为里面内容
<?php
require_once(dirname(__FILE__)."/include/common.inc.php");
require_once(dirname(__FILE__)."/include/channelunit.func.php");
require_once(dirname(__FILE__)."/include/dedetag.class.php");
if($action ==
'tpl'){
require_once(dirname(__FILE__)."/include/dedetemplate.class.php");
//设定模版目录,下面可以直接填入文件名
$tpl
= new DedeTemplate(dirname(__FILE__));
//载入模版文件
$tpl
->LoadTemplate('code.tpl.htm');
//---------------华丽丽的分割线------------
$title="我的DedeCMS网站";
$tpl
->SetVar("title",$title);
$arr=array(
name
=> 'DedeCMS',
company => 'DesDev
INC'
);
$tpl ->SetVar("arr",$arr);
$obj
= new stdclass;
$obj ->name='tianya';
$obj
->email='tianya@163.com';
$obj ->now
=time();
$tpl ->SetVar("obj",$obj);
$isshow =
true;
$tpl
->SetVar("isshow",$isshow);
//显示页面
//$tpl
->Display();
//生成htm文件
$tpl
->SaveTo('code.htm');
exit();
}
?>
设定文件名code.tpl.htm,以下为其内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
{dede:var name='title'/}<br />
名字:{dede:var.arr.name/}<br />
公司:{dede:var.arr.company/}<br
/>
{dede:cfg.webname/}<br />
{dede:global.cfg_webname/}<br />
{dede:object.obj->name/}<br />
{dede:object.obj->email/}<br
/>
{dede:object.obj->now function="MyDate('Y-m',@me)"/}<br
/>
遍历数组:<br />
{dede:array.arr
comment='这里是注释的位置'}
{dede:key/} = {dede:value/}<br
/>
{/dede:array}
{dede:php}
echo "hello word";
{/dede:php}
<br
/>
{dede:if
var.isshow}
需要显示
{else}
不需要显示
{/dede:if}
<br
/>
{dede:tianya name='hello' rstype='string'/}
<br
/>
{dede:memberlist}
{dede:field.mid/}-{dede:field.uname/}<br
/>
{/dede:memberlist}
{dede:include
filename='footer.tpl.htm'/}
</body>
</html>
设定文件名footer.tpl.htm其内容为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html; charset=gb2312"
/>
<title>{dede:var
name='title'/}</title>
</head>
<body>
<br
/>-----------------------------------------------------------<br />
CMS和网站运营 is Powered by WordPress. Keso theme by dupola
</body>
</html>
相关文章推荐
- windows 正在运行文件,可以等windows工作完或者先关闭文件后再退出windows”
- 黑客如何快速查找网站后台地址方法整理
- PHP获取 ,根目录,当前文件路径,上层目录路径 ,文件名,扩展名
- is_file(\'images/xx.gif\'); 能找到,is_file(\'/images/xxx.gif\')就找不到了fi le_exists()
- phpMyAdmin“无法载入mysql扩展,请检查PHP配置
- WINDOWS7IIS7.5配置PHP环境
- 请问屏幕保护程序对液晶显示器有没有损害?
- iss6 iis7 iis7.5 apache 设置脚本权限方法。
- ecshop对不起,商品库存不足,请您修改数量!
- ping过后显示ttl=59是 什么意思?
- 修改表前缀 dede提示“读取附加信息出错”的解决办法
- IIS&Apache虚拟主机设置(主机头,一服多站)
- 利用安全狗防护DedeCMS v5.7高危注入漏洞 [复制链接]
- jquery让div中所有的a标签的target属性为“_blank”
- HTML5开发移动APP原理介绍
- 数据库导入文件命令load data详解
- 多线程(pthread、NSThread、GCD)
- AFNetworking 2.5.0版本的使用
- zookeeper 集群配置
- [google] 怎么使用google搜索