搜尋
首頁php教程php手册smarty的section嵌套循环用法示例,smartysection

smarty的section嵌套循环用法示例,smartysection

本文实例讲述了smarty的section嵌套循环用法。分享给大家供大家参考,具体如下:

{section name="sec1" loop=$typeList}
<TABLE class=left20 height=25 cellSpacing=0 cellPadding=0 width=624 
  background=images/indexbg.gif border=0>
   <TBODY>
   <TR>
    <TD class=zi align=left width=554 height=25>  <FONT 
     color=#ffffff><B>{$typeList[sec1].typeName}</B></FONT></TD>
    <TD vAlign=top width=70 height=25><a href="hot.html"><img src="/static/imghwm/default1.png"  data-src="images/more.gif"  class="lazy"    style="max-width:90%"  style="max-width:90%" 
   border=0></a></TD>
   </TR></TBODY></TABLE>
  <table cellspacing="0" cellpadding="0">
   <tr> 
{section name="sec2" loop=$typeList[sec1].shop}
    <td><table cellspacing="0" cellpadding="0">
      <tr>
       <td valign="center" align="middle" width="116"><table cellspacing="0" cellpadding="0">
         <tr>
          <td><a href="show_prop.php&#63;id={$typeList[sec1].shop[sec2].id}" target="_blank"><img  src="/static/imghwm/default1.png"  data-src="http://localhost/{$typeList[sec1].shop[sec2].img_url}"  class="lazy"    style="max-width:90%"  style="max-width:90%" border="0" alt="smarty的section嵌套循环用法示例,smartysection" ></a></td>
         </tr>
       </table></td>
      </tr>
      <tr>
       <td class="hongzi" align="middle"> <a href="a01.htm">{$typeList[sec1].shop[sec2].name} </a> </td>
      </tr>
      <tr>
       <td class="zi2" align="middle">数量:{$typeList[sec1].shop[sec2].num} 个 </td>
      </tr>
      <tr>
       <td class="zi2" align="middle">价格:{$typeList[sec1].shop[sec2].price} 白金币 </td>
      </tr>
    </table></td>
{/section}
    </tr>
</table>
{/section}

将sec1 的 $typeList[sec1].shop 作为sec2的loop

就可以取到shop其中的数组的内容

更多关于Smarty相关内容感兴趣的读者可查看本站专题:《smarty模板入门基础教程》、《PHP模板技术总结》、《PHP基于pdo操作数据库技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),