-2
有誰知道如何在Smarty模板中集成HTML/CSS?我是Smarty模板引擎的新手。請在此建議儘可能多的幫助。如何在Smarty中集成HTML
有誰知道如何在Smarty模板中集成HTML/CSS?我是Smarty模板引擎的新手。請在此建議儘可能多的幫助。如何在Smarty中集成HTML
首先,您必須上傳「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>
現在,打你的索引頁。它應該像你期望的那樣顯示你的模板。