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.

matrix pagination page numbers - pixel & tonic

August 28, 2011 4:40pm

Subscribe [3]
  • #1 / Aug 28, 2011 4:40pm

    thefifthlion

    133 posts

    So after a few days I finally figured out how to accomplish pagination/page numbers with Matrix. It took me forever and there wasn’t a demo anywhere so I hope this helps someone else. You’ll need the Simple Math plugin as suggested by Pixel & Tonic.

    sample code
    —————————-

    {preload_replace:rows_per_page="12"} 
    <ul>
    {exp:channel:entries channel="galleries" url_title="{segment_2}" dynamic="no"}
    {gallery}          
    {if row_count <= {exp:simple_math calculate='ceil({total_rows}/{rows_per_page})'}}
       {if {exp:simple_math calculate='({row_count}-1)*{rows_per_page}'} == '{segment_3}'}<li><a href="http://{path=%27gallery/{segment_2}/{exp:simple_math" class="selected">{row_count}</a></li>
       {if:else}<li><a href="http://{path=%27gallery/{segment_2}/{exp:simple_math">{row_count}</a></li>{/if}
    {/if}
    {/gallery}
    {/exp:channel:entries}
    </ul>

     

    description of code
    —————————-
    • rows_per_page variable should be set to however many thumbs you want displayed in gallery
    • first parent if conditional loops through to get page count
    • second and third conditional check to highlight current page (setup css for class for “selected”)
    • ceil= stands for ceiling and is used in the Simple Math tag to round up to get the total pagination count
    • url_title=”{segment_2}” //limits the query to just one matrix entry like “rings” or “pendants” for example
    • {segment_2} second url segment “example: rings in the following url”
    • {segment_3} third url segment “example: 24 in the following url”

    <a href="http://www.website.com/index.php/gallery/rings/24">http://www.website.com/index.php/gallery/rings/24</a>
  • #2 / Feb 02, 2012 7:44am

    soundseller

    52 posts

    Awesome, saved me a lot of headaches.
    Thnx

  • #3 / May 16, 2012 8:25am

    Sjoerd

    233 posts

    Thanks man, awesome! Saved me a lot of time and headache.

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

ExpressionEngine News!

#eecms, #events, #releases