PHPackages                             sjaakp/yii2-loadmore - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sjaakp/yii2-loadmore

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

sjaakp/yii2-loadmore
====================

Load More button for Yii 2.0 GridView or ListView

1.0.1(1y ago)927.2k↓34.9%3[1 issues](https://github.com/sjaakp/yii2-loadmore/issues)[1 PRs](https://github.com/sjaakp/yii2-loadmore/pulls)MITPHP

Since Apr 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sjaakp/yii2-loadmore)[ Packagist](https://packagist.org/packages/sjaakp/yii2-loadmore)[ RSS](/packages/sjaakp-yii2-loadmore/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

yii2-loadmore
=============

[](#yii2-loadmore)

#### Load More button for Yii2

[](#load-more-button-for-yii2)

[![Latest Stable Version](https://camo.githubusercontent.com/72d4c9bc3f82f0ac69a897628ed06d2512246bfc7a29ece21d429f39f04bd7e9/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d6c6f61646d6f72652f762f737461626c65)](https://packagist.org/packages/sjaakp/yii2-loadmore)[![Total Downloads](https://camo.githubusercontent.com/cf25e91ff5f9354a48a262dfde8a711865c712fce074e6dde9c0632347b05cad/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d6c6f61646d6f72652f646f776e6c6f616473)](https://packagist.org/packages/sjaakp/yii2-loadmore)[![License](https://camo.githubusercontent.com/094c6493d5b1d132b3f6e5b070ba7b457bd975bee44311d320b92acdb9ec4791/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d6c6f61646d6f72652f6c6963656e7365)](https://packagist.org/packages/sjaakp/yii2-loadmore)

**LoadMorePager**, the main part of the **yii2-loadmore** package, is a widget that can be used as a pager for a [GridView](https://www.yiiframework.com/doc/api/2.0/yii-grid-gridview "Yii2") or a [ListView](https://www.yiiframework.com/doc/api/2.0/yii-widgets-listview "Yii2")of the [Yii 2.0](https://www.yiiframework.com/ "Yii") PHP Framework. In stead of the usual [LinkPager](https://www.yiiframework.com/doc/api/2.0/yii-widgets-linkpager "Yii"), a 'Load More' button is rendered. Clicking it, adds a bunch of new items to the list. With every click, the list grows until there are no more items to show.

A demonstration of **LoadMorePager** is [here](http://www.sjaakpriester.nl/software/loadmore).

Installation
------------

[](#installation)

Install **yii2-loadmore** in the usual way with [Composer](https://getcomposer.org/). Add the following to the `require` section of your `composer.json` file:

`"sjaakp/yii2-loadmore": "*"`

or run:

`composer require sjaakp/yii2-loadmore`

You can manually install **yii2-loadmore** by [downloading the source in ZIP-format](https://github.com/sjaakp/yii2-loadmore/archive/master.zip).

Using LoadMorePager
-------------------

[](#using-loadmorepager)

Use **LoadMorePager** in a **GridView** just by setting the latter's [`pager`](https://www.yiiframework.com/doc/api/2.0/yii-widgets-baselistview#$pager-detail "Yii2") property to a configuration array with the former's class, like:

```

...

...

```

That's all that's needed for basic functionality. The Load More button will appear as a standard link. In a **ListView**, set the `pager` property likewise.

Options
-------

[](#options)

**LoadMorePager**'s options can be set like so:

```

...

...

```

**LoadMorePager** has four options:

#### label

[](#label)

`string` The text of the Load More button. Default: `'Load more'`.

#### id

[](#id)

`string` The HTML ID of the Load More button. If not set (default) it will be auto-generated.

#### options

[](#options-1)

`array` The HTML options of the Load More button. Set this to something like `[ 'class' => 'btn btn-secondary' ]` to give the button the looks of a real button (assuming that you use Bootstrap). Default: `[]` (empty array).

#### indicator

[](#indicator)

`string` Optional. The CSS selector for the indicator element(s). While the list is waiting for new items, the indicator element(s) get the extra CSS class `'show'`. Great for showing a 'spinner' after the Load More button is clicked. Default: `null`.

Refinement 1: summary
---------------------

[](#refinement-1-summary)

In its basic setup, **LoadMorePager** will not update the **GridView**'s or **ListView**'s summary, if present. To correct that, wrap the `{end}` token in the list's [`summary` setting](https://www.yiiframework.com/doc/api/2.0/yii-widgets-baselistview#$summary-detail "Yii2")with a `` having the class `'summary-end'`. For example:

```

...
