PHP smarty函數

模板繼承php

fuji.htmlcss

<title><{block name='biaoti'}><{/block}></title>
 <{block name='head'}><{/block}>
 <style type="text/css">
 .menu
 {
     width:100%;
     height:80px;
     background-color:#06F;     
 }
 .menus
 {
     float:left;
     width:100px;
     height:80px;
     line-height:80px;
     vertical-align:middle;
     text-align:center;
     margin-left:80px;
     color:#FFF; 
 }
 .dibu
 { 
     width:100%;
     height:100px;
     background-color:#06F;
     line-height:100px;
     vertical-align:middle;
     text-align:center;
     color:#FFF; 
 } 
 </style>
 
</head>

<body>
<div class="menu">
    <div class="menus">主頁</div>
    <div class="menus"><{$jianjie}></div>
    <div class="menus"><{$xinwen}></div>
    <div style="clear:both"></div>
</div>
<div style="width:100%;">
    <{block name='neirong'}><{/block}>
</div>
<div class="dibu">
      底部信息  
</div>
</body>

zi.htmlhtml

<{extends file='fuji.html'}>
<{block name='biaoti'}>
    子模板  
<{/block}>
<{block name='head'}>
  <style type="text/css">
      .neirong
    {
        width:100%;
        height:350px;
        color:#666;
    }
  </style>
<{/block}>
<{block name='neirong'}>
  <div class="neirong">
      <br>這是子模板
  </div>  
<{/block}>

zi.phpspa

<?php
include("../init.inc.php");
include("../../dbda.php");
$db=new DBDA();

$smarty->assign("jianjie","簡介");
$smarty->assign("xinwen","新聞");

$smarty->display("zi.html");

相關文章
相關標籤/搜索