1

I hear rumors that this is possible.

I want to set up a photo gallery that only shows 10 of 100+ photos. User click paginated links to see more photos.

Anybody ever have to set this up? I hear a rumor it requires Simple Math?

If you have a solution, share it!

1

Here's a fairly simple pagination with only a previous and next button example. It should give you a good place to start. The example uses pagination number in the 3rd segment and instead of Simple Math uses Math plugin. May have over commented, but:

{!--   how many matrix rows per page?   --}
{preload_replace:rows_per_page="2"}

{exp:channel:entries channel="YOUR_CHANNEL" url_title="YOUR_URL_TITLE" dynamic="no"} 

    {if YOUR_MATRIX_FIELD}

        {!--   matrix rows   --}
        {YOUR_MATRIX_FIELD offset="{segment_3}" limit="{rows_per_page}"}
            {cell_1}<br>
            {cell_2}<br>
            {cell_3}
            {!--   etc...   --}
            <hr>
        {/YOUR_MATRIX_FIELD}    

        {!-- ---------------------- 
        previous link 
        ---------------------- --}
        {!--   if we're on the second page   --}
        {if "{segment_3}" == "{rows_per_page}"} 
            <a href="{path='YOUR_TEMPLATE_GROUP/YOUR_TEMPLATE'}">Prev</a>  

        {!--   else if we're further along in pages   --} 
        {if:elseif "{segment_3}" > "{rows_per_page}"} 
            <a href="{path='YOUR_TEMPLATE_GROUP/YOUR_TEMPLATE/{exp:math formula='{segment_3} - {rows_per_page}' absolute='yes'}'}">Prev</a>   
        {/if}

        {!-- ---------------------- 
        next link 
        ---------------------- --}
        {!--   if the total matrix rows are greater than sum of pagination segment plus rows per page   --}
        {if "{YOUR_MATRIX_FIELD:total_rows}" > "{exp:math formula='{segment_3} + {rows_per_page}' absolute='yes'}"}
            {!--   if not on the first page calculate next page segment, else show link to second page   --}
            <a href="{path='YOUR_TEMPLATE_GROUP/YOUR_TEMPLATE/{if segment_3}{exp:math formula='{segment_3} + {rows_per_page}' absolute='yes'}{if:else}{rows_per_page}{/if}'}">Next</a>   
        {/if}

    {/if}
{/exp:channel:entries} 

(this example builds on a related answer here)

| improve this answer | |
0

First don't get it to work (next area) {YOUR_MATRIX_FIELD:total_rows} returns the entry of cell_1 if I use

if "{{YOUR_MATRIX_FIELD limit="1"}{field_total_rows}{/YOUR_MATRIX_FIELD}}" > "{exp:math formula='{segment_3} + {rows_per_page}' absolute='yes'}"}

It works fine

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.