| |
|
|
·çÇÁ󸮸޼µå´Â ¸Þ¼µå À̸§¿¡ push °¡ ÀÖ´Â °Í°ú ¾ø´Â °ÍÀ¸·Î ±¸ºÐÇÒ ¼ö ÀÖÀ¸¸ç, push°¡ ÀÖ´Â ¸ðµç ¸Þ¼µå´Â, ·çÇÁÀÇ ±¸°£(¼½¼Ç)À» ¹ß»ý½ÃŰ´Â ±â´ÉÀ» °øÅëÀ¸·Î ¼öÇàÇÕ´Ï´Ù. push ¸Þ¼µåµéÀÇ ½ÇÇà ȸ¼ö¸¸Å ¼½¼ÇÀÌ ¹ß»ýÇÕ´Ï´Ù.
| some.tpl |
>>output |
{ @ someloop }
-- TEMPLATE SECTION --
<div>
{ someloop.variable }
</div>
{ / }
|
<div>
value 1
</div>
|
-- SECTION 1 --
|
<div>
value 2
</div>
|
-- SECTION 2 --
|
...
...
|
¾Æ·¡ÀÇ ¿¹Á¦´Â ½ÇÇàÆÄÀÏÀÇ ·çÇÁ°¡ 3ȸ µ¹Áö¸¸ ¼½¼ÇÀÌ ¹ß»ýÇÏÁö ¾Ê¾Æ Ãâ·ÂµÇÁö ¾ÊÀº °æ¿ìÀÔ´Ï´Ù.
| index.php |
...
$fruit=array(1=>'apple','orange','melon');
$tpl->loopLoad('fruit');
foreach ($fruit as $num => $name) {
$tpl->loopAssign(array(
'num' =>$num,
));
$tpl->loopAssign(array(
'name' =>$name,
));
}
...
|
| index.tpl |
<table>
{@ fruit}
<tr><td>{ .num }</td><td>{ .name }</td></tr>
{/}
</table>
|
| >>output |
<table>
</table>
|
¾Æ·¡ÀÇ ¿¹Á¦´Â push¸Þ¼µåÀÇ Áߺ¹»ç¿ëÀ¸·Î ¼½¼ÇÀÌ 6°³ ¸¸µé¾îÁø °æ¿ìÀÔ´Ï´Ù.
| index.php |
...
$fruit=array(1=>'apple','orange','melon');
$tpl->loopLoad('fruit');
foreach ($fruit as $num => $name) {
$tpl->loopPushAssign(array(
'num' =>$num,
));
$tpl->loopPushAssign(array(
'name' =>$name,
));
}
...
|
| >>output |
<table>
<tr><td>1</td><td></td></tr>
<tr><td></td><td>apple</td></tr>
<tr><td>2</td><td></td></tr>
<tr><td></td><td>orange</td></tr>
<tr><td>3</td><td></td></tr>
<tr><td></td><td>melon</td></tr>
</table>
|
½ÇÇàÆÄÀÏÀÇ ·çÇÁ¿¡¼, ù ·çÇÁ¸Þ¼µå¿¡¸¸ push¸¦ ³ÖÀ¸¸é ¿øÇÏ´Â Ãâ·ÂÀ» ¾òÀ» ¼ö ÀÖ½À´Ï´Ù.
| index.php |
...
$fruit=array(1=>'apple','orange','melon');
$tpl->loopLoad('fruit');
foreach ($fruit as $num => $name) {
$tpl->loopPushAssign(array(
'num' =>$num,
));
$tpl->loopAssign(array(
'name' =>$name,
));
}
...
|
| >>output |
<table>
<tr><td>1</td><td>apple</td></tr>
<tr><td>2</td><td>orange</td></tr>
<tr><td>3</td><td>melon</td></tr>
</table>
|
½ÇÁ¦ÀÛ¾÷ÇÒ ¶§´Â loopPushAssign() ¸Þ¼µå¸¦ ÇÑ ¹ø¸¸ »ç¿ëÇϰí Çʿ信 µû¶ó ¿¹¾àº¯¼ö¸¦ Ȱ¿ëÇϸé, ´ëºÎºÐÀÇ ·çÇÁº¯¼öÇÒ´çÀ» ó¸®ÇÒ ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.
´ÙÀ½Àº ·çÇÁ¸Þ¼µå¸¦ ¹Ù¸£°Ô »ç¿ëÇÑ ¿¹Á¦µéÀÔ´Ï´Ù. pushÀÇ À§Ä¡¸¦ È®ÀÎÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.
| index1.php |
...
$tpl->loopLoad('abc');
while (...) {
$tpl->loopPushAssign(array(;
...
));
...
$tpl->loopAssign(array(
...
...
));
}
...
|
| index2.php |
...
$tpl->loopLoad('abc', 1);
while (...) {
$tpl->loopPushLoad('xyz', 2);
while (...) {
$tpl->loopPushAssign(array(
...
), 2);
}
$tpl->loopAssign(array(
...
...
), 1);
}
...
|
| index3.php |
...
$tpl->loopLoad('aaa', 1);
while (...) {
$tpl->loopPushAssign(array(;
...
...
));
$tpl->loopLoad('bbb', 2);
while (...) {
$tpl->loopPushLoad('ccc', 3);
while (...) {
$tpl->loopPushAssign(array(
...
...
), 3);
}
$tpl->loopAssign(array(
...
), 2);
}
$tpl->loopAssign(array(
...
...
), 1);
}
...
|
| index4.php |
...
$tpl->loopLoad('aaa', 1);
while (...) {
$tpl->loopPushLoad('xxx', 2);
while (...) {
$tpl->loopPushAssign(array(
...
...
), 2);
}
$tpl->loopLoad('yyy', 2);
while (...) {
$tpl->loopPushAssign(array(
...
...
), 2);
}
$tpl->loopLoad('zzz', 2);
while (...) {
$tpl->loopPushAssign(array(
...
...
), 2);
}
}
...
|
|
|