作者carlcarl (carl)
看板PHP
标题Re: [请益] smarty 前端html 问题
时间Wed Nov 16 12:24:20 2011
※ 引述《EJB (JAVA.net)》之铭言:
: 想请问一下
: 最近新网站要把php html code分开
: 按照以前所学到 我选择用smarty 来架构
: 但目前遇到一个问题 网路上一直找不到方向
: 我想在前端网址部分呈现是 http://url/xxx.html?xxxxxx
: 但很多smarty 文章都是写 http://url/xxx.php?xxxxx
: 主要我想把php都丢到後面逻辑运算就好 前端Jquery 和 html就好
: 想请问我该从哪边改写? 不知道我这样表达清不清楚 thx
不太懂为什麽一定要指定副档名为html?
smarty 一个网页可以分为php和tpl(网页显示)两个档案
smarty的作法是去读php
然後php处理完後 如果需要显示的话 最後再加上call 对应tpl的function就好
所以一样能够将显示和处理的逻辑分开
大致样子可能像以下这样
a.php
<?php
//处理东西
$tpl = new smarty
$tpl->assign('aa',aa)
$tpl->display(a.tpl)
?>
==================================
a.tpl
<html>
<head>
<title>a</title>
</head>
<body>
{if aa == 1}
aa
{/if}
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.105.191
1F:推 mervynW:php handler 指到 .html 不就的了 11/16 12:50
2F:→ EJB:是上面要求 我只好想办法做 11/16 13:08
3F:→ EJB:不过谢谢 回答XD 11/16 13:09
4F:推 shadowjohn:小改一下 httpd.conf 的设定即可 11/16 13:10
5F:→ shadowjohn:AddType application/x-httpd-php .php .html .htm 11/16 13:11
6F:推 shadowjohn:AddHandler application/x-httpd-php .php .htm 11/16 13:13
7F:→ shadowjohn:上面那行可以放 .htaccess or php.ini 11/16 13:14