phpcms2008 代码简介:模板解析(2)

来源:互联网 发布:淘宝如何买烟 编辑:程序博客网 时间:2024/06/06 04:28

 

 

   看了一下首页,想看它是怎么解析的。

 

 流程是

index.php = > function template('phpcms', 'index'); =>function template_compile() =>template /default/phpcms/index.html   =>template_parse () 

 

示例:

 

   如 template /default/phpcms/index.html 中的 {tag_首页幻灯片} ,首先将这个内容标签解析成 get_tag('首页幻灯片');然后再解析成 template/default/tag.inc.php中的 array('首页幻灯片')并返回以下值

 

  '首页幻灯片' => 'tag(/'phpcms/', /'tag_content_slide/', "SELECT a.contentid,a.catid,a.typeid,a.areaid,a.title,a.style,a.thumb,a.keywords,a.description,a.userid,a.updatetime,a.inputtime,a.url FROM `phpcms_content` a, `phpcms_content_position` p WHERE a.contentid=p.contentid AND p.posid=2 AND a.status=99   AND  `thumb`!=/'/'  ORDER BY a.contentid DESC", 0, 5, array (  /'class/' => /'url/',  /'target/' => /'_blank/',  /'width/' => /'296/',  /'height/' => /'164/',))',

 

然后得到 data/cache_template/phpcms_index.tpl.php编译后的文件;

 

而其中幻灯片的<?php echo tag('phpcms', 'tag_content_slide', ....);?>  将include/global.func.php 中的function tag()将解析其中的sql语句并得到数据$data及$pages,

最后调用标签模板 template/default/phpcms/tag_content_slide.html