jan-vince / smallrecords

OctoberCMS plugin to store and manage records and lists
MIT License
30 stars 11 forks source link

Pagination? #94

Closed W5DEV closed 11 months ago

W5DEV commented 2 years ago

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?

jan-vince commented 2 years ago

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.

grafxflow commented 12 months ago

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

jan-vince commented 12 months ago

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

grafxflow commented 12 months ago

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' %}
jan-vince commented 12 months ago

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 commented 12 months ago

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

grafxflow commented 12 months ago

Perfect thanks for all your help :)