thinkPHP 模板的提示(十三)

來源:互聯網
上載者:User

標籤:header   post   檔案名稱   think   不同   開源   art   ack   url   

模板的提示:頁面跳轉 、模板包括、模板渲染、模板的繼承

        

  頁面跳轉
<a href=‘__URL__/index‘>我要跳轉到首頁面。用這種方法!</a>

一、模板包括
<include file="完整模板檔案名稱" />
<include file="./Tpl/default/Public/header.html" /> //完整路徑
<include file="read" /> //匯入當前模組下的read操作模板
<include file="Public:header" /> //包括Public模組下的header操作模板,
  //注意不須要header控制器支援,僅僅要Public下有header.html檔案就可以引入
*比方你的訪問的是Home/Tpl/Index/index  -->Index/index.html要引用公用的模板檔案header.html
1:不同模組下,直接在index.html加上(Home/Tpl/Publi/header.html ):
--  <include file="Public:header" />
2:同級模組下。(Home/Tpl/Index下)
--  <include file="read" />
<include file="blue:User:read" /> //包括blue主題的User模組的read操作模板
<include file="$tplName" />
<include file="header" title="ThinkPHP架構"keywords="開源WEB開發架構"/>
在模板中變數用[變數]接受
<include file=‘file1,file2‘ />


二、模板渲染
1、自己主動開啟模板渲染 設定設定檔
‘LAYOUT_ON‘=>true,//開啟模板渲染
A:準備一個模板渲染頁面,在頁面中使用 {__CONTENT__} 接受詳細模板頁面的內容
B:假設在摸一個詳細模板中不希望使用渲染模板,能夠在頁首加入  {__NOCONTENT__}

2、不開啟自己主動模板渲染能夠在每個詳細頁面的頁首加入
<layout name=‘layout‘/>

3.提示
在渲染模板檔案裡也能夠使用其它模板檔案的內容
<include file=‘Public:header‘/>  //公用的標頭檔
<body>
<p>這裡是渲染頁面。!

!</p>
{__CONTENT__}
</body>
</html>


三、模板的繼承

模板的繼承和模板的渲染有點類似,都是先做好一個父級的一個公用模板,能後其它莫來引入---為

子模板,子模板繼承父級模板

thinkPHP 模板的提示(十三)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.