thinkPHP 模板的提示(十三)

來源:互聯網
上載者:User

標籤:thinkphp 模板的提示十三

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

        

  頁面跳轉
<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.