Smarty에서 루프를 중첩하는 방법

*文
풀어 주다: 2023-03-18 21:20:01
원래의
1267명이 탐색했습니다.

Smarty에서 루프를 중첩하는 방법은 무엇입니까? 이 글은 주로 smarty에서 섹션 중첩 루프의 사용을 소개하고, 섹션을 사용하여 중첩 루프 작업을 수행하는 Smarty의 구현 기술을 간단한 예제 형식으로 분석합니다. 그것이 모두에게 도움이 되기를 바랍니다.

자세한 내용은 다음과 같습니다.

{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="images/more.gif" width="53" height="25" 
   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?id={$typeList[sec1].shop[sec2].id}" target="_blank"><img src="http://localhost/{$typeList[sec1].shop[sec2].img_url}" width="84" height="88" border="0"></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의 루프로 사용하세요

shop에서 배열의 내용을 가져올 수 있습니다

관련 권장 사항:

방법 Smarty 템플릿 조절기에서 변수를 사용하려면

Smarty가 간단한 양식 요소를 생성하는 방법

Smarty 템플릿 엔진이 캐시하는 방법에 대한 자세한 설명

위 내용은 Smarty에서 루프를 중첩하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!