嵌套{section}的聪明分页

时间:2010-01-11 10:39:00

标签: php pagination smarty

    Here is the Sample Code:
      {section name="firstlevel" loop=$xxx}
        <ul>
            {section name="secondlevel" loop=$xxx[firstlevel]}
               <li>$xxx[firstlevel][secondlevel].values</li>
            {/section}
        </ul>
      {sectionelse}
          No values
      {/section}
      {if $smarty.section.firstlevel.last}
         {include file="pagination.tpl"}
      {/if}

I have limited 10 records per page, but this smarty code not calling the include file pagination. Please suggest what wrong in it or give idea...

1 个答案:

答案 0 :(得分:0)

我不是Smarty大师,但我认为“last”只会在该部分中返回true。无论如何,这可能是更可取的,因为当没有记录时很少或没有显示分页的用途。

  {section name=firstlevel loop=$xxx}
    <ul>
        {section name=secondlevel loop=$xxx[firstlevel]}
           <li>$xxx[firstlevel][secondlevel].values</li>
        {/section}
    </ul>
    {if $smarty.section.firstlevel.last}
       {include file="pagination.tpl"}
    {/if}
  {sectionelse}
      No values
  {/section}