2017 © Pedro Peláez
 

symfony-bundle paginator-bundle

Symfony2's helper bundle for pagination

image

da/paginator-bundle

Symfony2's helper bundle for pagination

  • Thursday, October 6, 2016
  • by Gnucki
  • Repository
  • 3 Watchers
  • 0 Stars
  • 6,108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

DaPaginatorBundle

This Symfony2's bundle is an helper for managing paginated contents in an easy way. It is built on Pagerfanta., (*1)

Installation

Installation is a quick 2 steps process., (*2)

Step 1: Add in composer

Add the bundle in the composer.json file:, (*3)

// composer.json

"require": {
    // ...
    "pagerfanta/pagerfanta": "dev-master",
    "da/paginator-bundle": "dev-master"
},

Update your vendors with composer:, (*4)

composer update      # WIN
composer.phar update # LINUX

Step 2: Declare in the kernel

Declare the bundle in your kernel:, (*5)

// app/AppKernel.php

$bundles = array(
    // ...
    new Da\PaginatorBundle\DaPaginatorBundle(),
);

Usage

Paginated content definition

/**
 * @Route("/")
 * @Template()
 */
public function testAction()
{
    $paginator = $this->container->get('da_paginator.paginator');

    $paginatedContent = $paginator->defineOffsetPaginatedContent(
        array('id' => 'Id', 'name' => 'City Name'),
        'array',
        array(array(
            array('id' => 1,  'name' => 'madrid',    'desc' => 'none'),
            array('id' => 2,  'name' => 'berlin',    'desc' => 'none'),
            array('id' => 3,  'name' => 'london',    'desc' => 'none'),
            array('id' => 4,  'name' => 'boston',    'desc' => 'none'),
            array('id' => 5,  'name' => 'chicago',   'desc' => 'none'),
            array('id' => 6,  'name' => 'new york',  'desc' => 'none'),
            array('id' => 7,  'name' => 'sidney',    'desc' => 'none'),
            array('id' => 8,  'name' => 'paris',     'desc' => 'none'),
            array('id' => 9,  'name' => 'tokyo',     'desc' => 'none'),
            array('id' => 10, 'name' => 'hong kong', 'desc' => 'none'),
            array('id' => 11, 'name' => 'pekin',     'desc' => 'none'),
            array('id' => 12, 'name' => 'bombay',    'desc' => 'none')
        )),
        'skip',
        'limit'
    );

    return array('cities' => $paginatedContent);
}

defineOffsetPaginatedContent allows you to define a paginated content. array means you use a data in an array form but you can use a doctrine query builder, callbacks and many others., (*6)

You can use an offset/length pattern or a page/per_page pattern and define your own labels (here skip/limit)., (*7)

Paginated content display

{{ da_paginator.render(cities, 'bootstrap')|raw }}

render allows you to render a paginated content in a fast and customized way., (*8)

Documentation

You can do a lot more things like formatting the content of a column. Let's take a look at the full documentation to have more explanations and see advanced features!, (*9)

The Versions

06/10 2016

dev-master

9999999-dev http://github.com/Gnuckorg/DaPaginatorBundle

Symfony2's helper bundle for pagination

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thomas Prelot

helper bundle symfony pagination paginator