yiistranaadapter A quick adapter (installable via composer) for the Strana pagination composer package


Yii record adapter for Strana pagination composer package.


Include the repository and require in your composer.json file:

"require": {
    "lincsanders/yii_strana_adapter": "dev-master",

Github: https://github.com/lincsanders/yii_strana_adapter

Packagist: https://packagist.org/packages/lincsanders/yii_strana_adapter


The usage is a little clunky, but it works. This is essentially a modified version of the "use your own adapter" example straight from https://github.com/usmanhalalit/strana. Substitute "User::model()" with your own stuff.

$strana = new \Strana\Paginator();
$configHelper = new \Strana\ConfigHelper($strana->perPage(5)->getConfig());
$adapter = new YiiStranaAdapter(User::model(), $configHelper);
$paginator = $strana->make(User::model(), $adapter);

This can be used in conjunction with something like the below to create your own paginated search results:

$criteria = new CDbCriteria;

    $criteria->addSearchCondition('username', $_GET['search']);

$model = User::model();

$strana = new \Strana\Paginator();
$configHelper = new \Strana\ConfigHelper($strana->perPage(5)->getConfig());
$adapter = new YiiStranaAdapter($model, $configHelper);
$paginator = $strana->make($model, $adapter);
0 0
1 follower
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: b4c0n
Created on: Feb 20, 2015
Last updated: 7 years ago

Related Extensions