ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Pagination inside <table> - best method?

November 15, 2011 5:57am

Subscribe [2]
  • #1 / Nov 15, 2011 5:57am

    DanL

    56 posts

    I have a template which outputs channel entries within a table structure, for example:

    <table>
     <thead>
      <th>Title 1</th>
      <th>Title 2</th>
     </thead>
     <tbody>
      {exp:channel:entries channel="my_channel" paginate="bottom" limit="10"}
      <tr>
       <td>{field_1}</td>
       <td>{field_2}</td>
      </tr>
      {/exp:channel:entries}
     </tbody>
    </table>

    Where should I then use the {paginate} tag pair?  Obviously it needs to go within the channel entries loop, but it will either break the table structure (placed with the <tbody>) or will be repeated each row if I nest within a new <tr><td>.

    I tried:

    <table>
     <thead>
      <th>Title 1</th>
      <th>Title 2</th>
     </thead>
     <tbody>
      {exp:channel:entries channel="my_channel" paginate="bottom" limit="10"}
      <tr>
       <td>{field_1}</td>
       <td>{field_2}</td>
      </tr>
      {/exp:channel:entries}
     </tbody>
    </table>
    {exp:channel:entries channel="my_channel" paginate="bottom" limit="10"}
     {paginate}...{/paginate}
    {/exp:channel:entries}

    ...but that did not work correctly.

  • #2 / Nov 15, 2011 9:04am

    Something like the following should work…

    <table>
     <thead>
      <th>Title 1</th>
      <th>Title 2</th>
     </thead>
     <tbody>
      {exp:channel:entries channel="my_channel" paginate="bottom" limit="10"}
      <tr>
       <td>{field_1}</td>
       <td>{field_2}</td>
      </tr>
    {if count == 10 || count == absolute_results}
     </tbody>
    </table>
    {paginate}...{/paginate}
    {/if}
    {/exp:channel:entries}
  • #3 / Nov 15, 2011 9:06am

    DanL

    56 posts

    Aha! I like it, thanks!

    EDIT: yes, works perfectly. Thanks again!

  • #4 / Nov 15, 2011 2:59pm

    Lisa Wess

    20502 posts

    Thanks for the input, caddisint!

    Dan, it looks like you have a viable solution, if anything else comes up, please do let us know.  Thank you!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases