欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Thinkphp5模板繼承和替換的問(wèn)題示例-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)Thinkphp5模板繼承和替換的問(wèn)題示例的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

從事服務(wù)器托管,服務(wù)器租用,云主機(jī),虛擬主機(jī),空間域名,CDN,網(wǎng)絡(luò)代維等服務(wù)。

Thinkphp5模板繼承和替換的問(wèn)題案例

同一個(gè)模塊下的common繼承問(wèn)題,這里于index模塊為例

Thinkphp5模板繼承和替換的問(wèn)題示例

在index模塊下有自己的common和模塊主視圖文件夾index,那么我index0里面繼承了自己的base.html是這樣的

(推薦教程:thinkphp教程)

//base.html文件
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>
      {block name="title"}
        雷小天thinkPHP開(kāi)發(fā)版
      {/block}
    </title>
    <link rel="stylesheet" type="text/css" href="__CSS__/style.css">
    <link rel="stylesheet" type="text/css" href="__LAYUI__/css/layui.css">
    <script type="text/javascript" src="__LAYUI__/layui.js"></script>
  </head>
  <body>
    <div class="wrap">
      <!-- 頭部 -->
      <div class="header">
        {include file="common/nav" /}
      </div>
      <!-- 中部 -->
      <div class="main">
        <!-- 邊欄 -->
        <div class="body">
          {block name="body"}
          {/block}
        </div>
        <!-- 內(nèi)容 -->
        <div class="sidebar">
          {block name="sidebar"}
          {/block}
        </div>
      </div>
      <!-- 尾部 -->
      <div class="footer">
        {block name="footer"}
          默認(rèn)值footer
        {/block}
      </div>
    </div>
  </body>
</html>

下面是index0.html

 {extend name="common/base" /}
{block name="title"}
  thinkPHP5 index頁(yè)
{/block}
{block name="body"}
  <h2>這里是index body</h2>
{/block}
{block name="sidebar"}
  <h2>這里是index sidebar</h2>
{/block}
{block name="footer"}
  index_22{__block__}
{/block}

我在index0.html文件中有重新定義title,所有最后的title是thimkPHP5 index頁(yè),但值得注意的是我footer內(nèi)容是index_22{__block__},而{__block__}指的是在模板base.html中同位置的默認(rèn)值footer,所有最后footer的內(nèi)容是index_22默認(rèn)值footer。

以上是同模塊下的繼承,還有一種是繼承common模塊的繼承,這里于idnex模塊下的view/index.html繼承common模塊下view下的base.html文件為例

Thinkphp5模板繼承和替換的問(wèn)題示例

不同的模塊繼承方式也不同了,這里繼承common模塊下的繼承方式為:{extend name="common@base" /},而在同模塊下的繼承是:

{extend name="common/base" /}。而有些需求在base.html文件中還需要繼承其他的模板,那么在base.html中可以這樣繼承:  {include file="common@header" /}這個(gè)意思就是繼承common下的view/header.html文件

感謝各位的閱讀!關(guān)于“Thinkphp5模板繼承和替換的問(wèn)題示例”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)頁(yè)標(biāo)題:Thinkphp5模板繼承和替換的問(wèn)題示例-創(chuàng)新互聯(lián)
瀏覽路徑:http://chinadenli.net/article48/gshep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)網(wǎng)站改版標(biāo)簽優(yōu)化響應(yīng)式網(wǎng)站企業(yè)網(wǎng)站制作App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化