Note:
This bundle has been replaced by the DatathekePagerBundle
You should use it instead
The GloomyPagerBundle allows you to display data with pagination, and to easily order and filter them.
4 services are available :
Features are :
Many wrappers
Array
Entity / ORM QueryBuilder
DBAL QueryBuilder
MongoDB
Datatheke.com
Null
Advanced filtering (AND/OR);
<?php
//...
$filters = array( 'operator' => 'and',
'criteria' => array( array( 'field' => 'job', 'operator' => 'contains', 'value' => 'Director' ),
array( 'operator' => 'or',
'criteria' => array(
array( 'field' => 'firstname', 'operator' => 'contains', 'value' => 'y' ),
array( 'field' => 'moviesNb', 'operator' => 'less', 'value' => 30 ),
)
)
)
);
Multiple ordering (order by lastname asc, firstname asc)
Ajax compatible
Many pagers on the same page
MIT
More exemples in the documentation
PHP
<?php
//...
/**
* @Template()
*/
public function crudAction()
{
return $this->get('gloomy.crud')->factory('MyBundle:MyEntity')->handle();
}
TWIG
{{ crud(crud) }}
PHP
<?php
//...
/**
* @Template()
*/
public function dataGridAction()
{
return array('datagrid' => $this->get('gloomy.datagrid')->factory('MyBundle:MyEntity'));
}
TWIG
{{ datagrid(datagrid) }}
PHP
<?php
//...
/**
* @Template()
*/
public function pagerAction()
{
return array('pager' => $this->get('gloomy.pager')->factory('MyBundle:MyEntity'));
}
TWIG
{% extends "::base.html.twig" %}
{% import 'GloomyPagerBundle:Pager:macros.html.twig' as helper %}
{% block stylesheets %}
{{ parent() }}
{{ helper.stylesheets() }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ helper.javascripts() }}
{% endblock %}
{% block body %}
<form action="{{ pager.pathForm() }}" method="post">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>{{ helper.orderBy( pager, 'firstname', 'Firstname' ) }}</th>
<th>{{ helper.orderBy( pager, 'lastname', 'Lastname' ) }}</th>
<th>{{ helper.orderBy( pager, 'job', 'Job' ) }}</th>
<th>{{ helper.orderBy( pager, 'moviesNb', 'Number of movies' ) }}</th>
</tr>
<tr>
<th>{{ helper.filter( pager, 'firstname' ) }}</th>
<th>{{ helper.filter( pager, 'lastname' ) }}</th>
<th>{{ helper.filter( pager, 'job' ) }}</th>
<th>{{ helper.filter( pager, 'moviesNb' ) }}</th>
</tr>
</thead>
<tbody>
{% for person in pager.items %}
<tr>
<td>{{ person.firstname }}</td>
<td>{{ person.lastname }}</td>
<td>{{ person.job }}</td>
<td>{{ person.moviesNb }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{# Allows submitting filters with 'Enter' #}
<input type="image" src="https://github.com/iamluc/GloomyPagerBundle/raw/master/{{ asset('bundles/gloomypager/img/transparent.gif') }}" height="0" width="0" border="0">
{{ helper.paginate( pager ) }}
</form>
{% endblock %}
composer.phar require "gloomy/pager-bundle" "dev-master"
<?php
//...
$bundles = array(
//...
new Gloomy\PagerBundle\GloomyPagerBundle(),
);
php app/console assets:install web --symlink