您的位置:首页 > 编程语言 > PHP开发

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

2009-08-17 15:42 246 查看
看了一下首页,想看它是怎么解析的。

流程是

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: