请问 tpl 文件用什么东东编译 我用dreamweaver 打开*.tpl 改动了一下 在按F12运行 。发现编译后的 %%B2^B29^B298BD0A%%index.tpl.php文件变成如下代码。 那么请问tpl文件用什么软件编译。
---
<?php /* Smarty version 2.6.19, created on 2013-01-27 14:47:15
compiled from 06/index.tpl */ ?>
<!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>{$title}</title>
<link rel='stylesheet' href="../css/style.css" />
</head>
<body>
<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
</body>
</html>
---
<?php /* Smarty version 2.6.19, created on 2013-01-27 14:47:15
compiled from 06/index.tpl */ ?>
<!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>{$title}</title>
<link rel='stylesheet' href="../css/style.css" />
</head>
<body>
<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
</body>
</html>
<title><?php echo $this->_tpl_vars['title']; ?>
</title>
<link rel='stylesheet' href="../css/style.css" />
</head>
<body>
<p>
<?php if ($_GET['type'] == 'tm'): ?>
欢迎光临,<?php echo $_GET['type']; ?><?php else: ?>
对不起,您不是本站VIP,无权访问此栏目。
<?php endif; ?>
</body>
----
当我在对应的tpl 文件的代码中把“欢迎光临”这几个字往后窜了窜 其他的都没有改</head>
<body>
<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
</body>
</html>
--- 在对应的index.php再按F12 运行
之后 编译的文件也就是那个%%%%index.tpl.php变为
<title>{$title}</title>
<link rel='stylesheet' href="../css/style.css" />
</head>
<body>
<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
</body>
---
问什么 那些<?php echo ... ?> 的标签都没有了呢 ?
<?php if ($_GET['type'] == 'tm'): ?>
欢迎光临,<?php echo $_GET['type']; ?>
<?php else: ?>
对不起,您不是本站VIP,无权访问此栏目。
<?php endif; ?> 会变成 这个样子 如下---<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
</body>
我在问问
如果我没有改tpl 输出结果是 : 对不起,您不是本站VIP,无权访问此栏目。
改了下tpl 输出的结果是 :{if $smarty.get.type == 'tm'} 欢迎光临,{$smarty.get.type} {else} 对不起,您不是本站VIP,无权访问此栏目。 {/if}
---
也就是把整个代码都输出了 。这个应该是木有什么影响吧
<?php
if(isset($_COOKIE['login'])){
$login = 1;
}
else{
$login = 0;
}$mysmarty->assign('login', $login);
$mysmarty->display('mytemplate.tpl');
?>
然后在mytemplate.tpl的模板页做smarty的if判断来输出“欢迎光临”和“对不起,您不是VIP”至于.tpl.php什么样子,你根本不用关心
它的 if .. else .. 写到tpl中 。
本来是拿个 练练 当没有改tpl 文件 就输出 : 对不起,您不是本站VIP,无权访问此栏目。
我就想拿这个tpl 练练 想写点自己东西 结果 就把自己写的代码全部输出了 。
我又把备份的tpl覆盖回来。干脆啥也不改只是把“ 对不起,您不是本站VIP,无权访问此栏目。 ” 这几个字往后窜了窜 ,结果 输出的 就是 ::{if $smarty.get.type == 'tm'} 欢迎光临,{$smarty.get.type} {else} 对不起,您不是本站VIP,无权访问此栏目。 {/if} ---- 也不知道为什么 。后来查看修改后%%%%index.tpl.php文件 ,和以前的比较 ,发现 改后的 %%%%index.tpl.php 文件中的 <?php ... ?> 都不见了
----- 比如 修改前 index.tpl.php
<?php if ($_GET['type'] == 'tm'): ?>
欢迎光临,<?php echo $_GET['type']; ?>
<?php else: ?>
对不起,您不是本站VIP,无权访问此栏目。
<?php endif; ?>
</body>
---
修改后就变成
<p>
{if $smarty.get.type == 'tm'}
欢迎光临,{$smarty.get.type}
{else}
对不起,您不是本站VIP,无权访问此栏目。
{/if}
所以默认的定界符 {、} 就原样输出了
---
我加了定界符
$smarty->left_delimiter = '<{'; // smarty 定界符开始
$smarty->right_delimiter = '}>'; // smarty 定界符结束 但tpl模板中 没有对应的使用这个定界符
现在好了 。问题解决 同样要感谢 deathoctopus 兄 。。
---