日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

smarty模板引擎总结六配置网站title,keywords,description

發布時間:2024/4/14 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 smarty模板引擎总结六配置网站title,keywords,description 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前臺樣式配置

作用:配置前臺一些數據 title,keys,網站的描述,一些css樣式

? ? ?在smarty初始化文件 smarty.inc.php

? ? ?$smarty->config_dir ? ?= "./conf"; // 前臺樣式配置目錄

? ? ?放在:/conf/ ?目錄

? ? ?文件命名: ?XXXXX.conf

? ? ?[模塊名]

? ? ?配置項名=值

? ? ?配置項名=值

? ? ?[模塊名2]

? ? ?配置項名=值

? ? ?配置項名=值

[index]

title = 欣才商城

keys ?= 欣才電腦 ?南京欣才電腦

description = 南京欣才


[index2]

title = 欣才商城2

keys ?= 欣才電腦2 ?南京欣才電腦2

description = 南京欣才2

? ??注意: 不需要加 ; "" '' ?這些符號!

? ? ?使用:

在模版文件的頭部引入配置文件

{config_load file="XXXX.conf" section="模塊名"}

? ? ?配置變量的輸出

1.{#配置項名#}

2.{$smarty.config.配置項名}

? ? ?注意:

1. 路徑計算

2. section:模塊名 如果不設置,調用公共,如果設置:section對應的模塊

1.在/smarty/下建立一個conf文件夾,在其下建立一個common.conf文件內容如下


[index] title?=?南京紅牛裝飾官網-南京裝修公司,南京裝飾公司,南京家裝公司 keywords??=?南京裝修公司,南京裝飾公司,南京家裝公司,南京紅牛裝飾 description?=?南京紅牛裝飾成立于1998年,先后被評為十大南京裝修公司,江蘇省明星企業,有裝修資質的南京裝飾公司,主營:南京家庭裝修,南京新房裝修,南京老房裝修,南京別墅裝修設計等。 [index2] title?=?標點裝修網 keywords?=?標點裝修網,標點金管家,裝修監理,家裝第三方平臺,裝飾公司 description?=?標點裝修網是一家免費專門的裝修監理網絡公司

2.Smarty.inc.php增加$smarty->config_dir = "./conf";

<?phprequire("./Autoloader.php");//require()引入smarty自動加載類文件Smarty_Autoloader::register();?//把register()方法注冊到自動加載類函數里面$smarty?=?new?SmartyBC();//創建smarty對象//smarty運行環境的配置$smarty->template_dir?=?"./template";?//配置模版目錄$smarty->compile_dir?=?"./comp";//配置編譯目錄$smarty->cache_dir?=?"./cache";//配置緩存目錄$smarty->config_dir?=?"./conf";//前臺樣式配置目錄 ?>

3.index.html頭部增加{config_load file="common.conf" section="index"}

{config_load?file="common.conf"?section="index"} <!DOCTYPE?html> <html> <head><title>{#title#}</title><meta?charset="utf-8"><meta?name="keywords"?content="{$smarty.config.keywords}"><meta?name="description"?content="{$smarty.config.description}"><script?type="text/javascript"?src="./public/Js/xxx.js"></script><link?type="text/css"?rel="stylesheet"?href="./public/Css/common.css"?/></head> <body><!--include引入模版頁面的路徑注意,header.html,footer.html,和index.html同級,不用./template/header.html-->{include?file="header.html"}<div?class="body"><h1>這是網站主體部分</h1></div>{include?file="footer.html"} </body> </html>

其他部分代碼不變,

4.header.html

<!DOCTYPE?html> <html> <head><title>網站頭部</title><meta?charset="utf-8"><meta?name="keywords"?content=""><script?type="text/javascript"?src="./public/Js/xxx.js"></script><link?type="text/css"?rel="stylesheet"?href="./public/Css/common.css"?/></head> <body><div?class="head">這是網站頭部</div> </body> </html>

5.footer.html

<!DOCTYPE?html> <html> <head><title>網站底部</title><meta?charset="utf-8"><meta?name="keywords"?content=""><script?type="text/javascript"?src="./public/Js/xxx.js"></script><link?type="text/css"?rel="stylesheet"?href="./public/Css/common.css"?/></head> <body><div?class="foot">這是網站底部</div> </body> </html>

6.index.php

<?phprequire("./Smarty.inc.php");//引入smarty的初始化文件$smarty->display("index.html");?//這行代碼要放到最后否則會報錯?>

轉載于:https://blog.51cto.com/it5808/1709502

總結

以上是生活随笔為你收集整理的smarty模板引擎总结六配置网站title,keywords,description的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。