-2

有谁知道如何在 Smarty 模板中集成 HTML/CSS?我是 Smarty 模板引擎的新手。请提出建议,因为这里需要帮助。

4

1 回答 1

0

首先,您必须上传“libs”文件夹。

接下来,您必须构建您的 index.php:

require('libs/Smarty.class.php');
$smarty = new Smarty();

$smarty->setTemplateDir('templates');
$smarty->setCompileDir('templates_c');
$smarty->setCacheDir('cache');
$smarty->setConfigDir('configs');
$template="home.tpl";
$smarty->display($template);

现在,您必须创建几个目录。从创建这些目录开始:

templates
templates_c
cache
configs

完成所有这些之后,您就可以制作模板了。这将被保存到“模板”目录中。给它命名home.tpl 你的模板就像普通的 HTML 一样:

<!DOCTYPE html>
<html>
<head>
<style>
* {
 margin: 0;
 padding: 0;
}
</style>
</head>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

现在,点击您的索引页面。它应该像您期望的那样显示您的模板。

于 2013-02-12T00:06:54.623 回答