smallrecords icon indicating copy to clipboard operation
smallrecords copied to clipboard

Pagination?

Open W5DEV opened this issue 3 years ago • 1 comments

Hello! My google-fu has apparently failed me on this, as this is the only reference I can find to pagination for SmallRecords. Is there anything built in to this plugin for quick pagination? I have the limit and allowlimit set, and I can operate the pages manually using the page/:slug tag in the URL, but as far as dynamic pages go, I have yet to figure out a way to design the pagination so that it works seamlessly with the plugin?

Do you happen to have some examples of how pagination was implemented with your plugin?

W5DEV avatar Jan 19 '22 22:01 W5DEV

Hi John,

if you use Bootstrap, you can simply use:

            <div>

                {{ records.items.render|raw }}
            
            </div>  

Just look in default view code (at the end): https://github.com/jan-vince/smallrecords/blob/master/components/records/default.htm https://github.com/jan-vince/smallrecords/blob/master/components/records/default.htm

Best regards,

Jan

< Ing. Jan Vince / webdesigner / +420 733 127 581 / www.vince.cz />

20. 1. 2022 v 0:00, John Larson @.***>:

Hello! My google-fu has apparently failed me on this, as this is the only reference I can find to pagination for SmallRecords. Is there anything built in to this plugin for quick pagination? I have the limit and allowlimit set, and I can operate the pages manually using the page/:slug tag in the URL, but as far as dynamic pages go, I have yet to figure out a way to design the pagination so that it works seamlessly with the plugin?

Do you happen to have some examples of how pagination was implemented with your plugin?

— Reply to this email directly, view it on GitHub https://github.com/jan-vince/smallrecords/issues/94, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINT72VHRIHBIM34F2EXILUW467HANCNFSM5MLGYEWQ. You are receiving this because you are subscribed to this thread.

jan-vince avatar Jan 20 '22 09:01 jan-vince

Can the pagination be customised for another framework such as tailwind?

grafxflow avatar Sep 10 '23 18:09 grafxflow

Sure, but you have to create HTML by yourself.

There are methods that you can use: https://docs.octobercms.com/1.x/services/pagination.html

jan-vince avatar Sep 10 '23 19:09 jan-vince

So at the moment I see the following.

{% if records.property('allowLimit') %}
    <div>
        {{ records.items.render | raw }}
    </div>
{% endif %}

I have noticed in the plugins/janvince/smallrecords/components/Records.php component there is.

/**
 *  Limit
 */
if( $this->property('allowLimit') and  $this->property('limit') ) {
    return $records->paginate($this->property('limit'), $this->property('pageSlug', 1));
}

I have tried the following from the help url but it causes a white page.

{{ records.render | raw }}

Would it be possible to use something like?

{% partial 'records/pagination' %}

grafxflow avatar Sep 10 '23 19:09 grafxflow

Paginated collection is {{ records.items }}.

You can use methods like {{ records.items.currentPage }}, {{ records.items.lastPage }}, {{ records.items.count }}, ... as they are documented on https://docs.octobercms.com/1.x/services/pagination.html#appending-to-pagination-links.

This way you can create your own pagination.

You can put it in a partial and call it like this: {% partial 'tools/pagination' items = records.items %}.

jan-vince avatar Sep 10 '23 19:09 jan-vince

Check this: https://octobertricks.com/tricks/customize-pagination-markup

jan-vince avatar Sep 10 '23 19:09 jan-vince

Perfect thanks for all your help :)

grafxflow avatar Sep 10 '23 20:09 grafxflow