Git Product home page Git Product logo

whiteoctoberpagerfantabundle's Introduction

This project is no longer maintained. If you are using it with Symfony 3.4, 4.4 or 5, you may want to use this fork instead.

WhiteOctoberPagerfantaBundle

Build Status Scrutinizer Quality Score SensioLabsInsight

Bundle to use Pagerfanta with Symfony.

Note: If you are using a 2.0.x release of Symfony2, please use the symfony2.0 branch of this bundle. The master branch of this bundle tracks the Symfony master branch.

The bundle includes:

  • Twig function to render pagerfantas with views and options.
  • Way to use easily views.
  • Way to reuse options in views.
  • Basic CSS for the DefaultView.

Installation

  1. Use Composer to download the library
php composer.phar require white-october/pagerfanta-bundle
  1. Then add the WhiteOctoberPagerfantaBundle to your application:

In Symfony < 4:

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
        // ...
    );
}

In Symfony 4 with Symfony Flex this will be done automatically for you.

  1. Configure and use things!

A) Creating a Pager is shown on the Pagerfanta documentation. If you're using the Doctrine ORM, you'll want to use the DoctrineORMAdapter

B) Rendering in Twig is shown below in the Rendering Pagerfantas section.

C) Configuration is shown through this document

Rendering Pagerfantas

First, you'll need to pass an instance of Pagerfanta as a parameter into your template. For example:

$adapter = new DoctrineORMAdapter($queryBuilder);
$pagerfanta = new Pagerfanta($adapter);
return $this->render('@YourApp/Main/example.html.twig', [
    'my_pager' => $pagerfanta,
]);

You then call the the Pagerfanta Twig extension, passing in the Pagerfanta instance. The routes are generated automatically for the current route using the variable "page" to propagate the page number. By default, the bundle uses the DefaultView with the default name. The default syntax is:

<div class="pagerfanta">
    {{ pagerfanta(my_pager) }}
</div>

By default, the "page" variable is also added for the link to the first page. To disable the generation of ?page=1 in the url, simply set the omitFirstPage option to true when calling the pagerfanta twig function:

{{ pagerfanta(my_pager, 'default', { 'omitFirstPage': true}) }}

You can omit template parameter to make function call shorter, default template will be used:

{{ pagerfanta(my_pager, { 'omitFirstPage': true }) }}

If you have multiple pagers on one page, you'll need to change the name of the page parameter. Here's an example:

<div class="pagerfanta">
    {{ pagerfanta(my_other_pager, 'default', {'pageParameter': '[page_other]'}) }}
</div>

Note the square brackets around page_other; this won't work without them.

Twitter Bootstrap

The bundle also has a Twitter Bootstrap view.

For Bootstrap 2:

<div class="pagerfanta">
    {{ pagerfanta(my_pager, 'twitter_bootstrap') }}
</div>

For Bootstrap 3:

<div class="pagerfanta">
    {{ pagerfanta(my_pager, 'twitter_bootstrap3') }}
</div>

For Bootstrap 4:

<div class="pagerfanta">
    {{ pagerfanta(my_pager, 'twitter_bootstrap4') }}
</div>

Custom template

If you want to use a custom template, add another argument:

<div class="pagerfanta">
    {{ pagerfanta(my_pager, 'my_template') }}
</div>

With options:

{{ pagerfanta(my_pager, 'default', { 'proximity': 2}) }}

See the Pagerfanta documentation for the list of possible parameters.

Rendering the page of items itself

The items can be retrieved using currentPageResults. For example:

{% for item in my_pager.currentPageResults %}
    <ul>
        <li>{{ item.id }}</li>
    </ul>
{% endfor %}

Translate in your language

The bundle also offers two views to translate the default and the twitter bootstrap views.

{{ pagerfanta(my_pager, 'default_translated') }}

{{ pagerfanta(my_pager, 'twitter_bootstrap_translated') }}

Adding Views

The views are added to the container with the pagerfanta.view tag:

XML

<service id="pagerfanta.view.default" class="Pagerfanta\View\DefaultView" public="false">
    <tag name="pagerfanta.view" alias="default" />
</service>

YAML

services:
    pagerfanta.view.default:
        class: Pagerfanta\View\DefaultView
        public: false
        tags: [{ name: pagerfanta.view, alias: default }]

Reusing Options

Sometimes you want to reuse options of a view in your project, and you don't want to write them all the times you render a view, or you can have different configurations for a view and you want to save them in a place to be able to change them easily.

For this you have to define views with the special view OptionableView:

services:
    pagerfanta.view.my_view_1:
        class: Pagerfanta\View\OptionableView
        arguments:
            - @pagerfanta.view.default
            - { proximity: 2, prev_message: Anterior, next_message: Siguiente }
        public: false
        tags: [{ name: pagerfanta.view, alias: my_view_1 }]
    pagerfanta.view.my_view_2:
        class: Pagerfanta\View\OptionableView
        arguments:
            - @pagerfanta.view.default
            - { proximity: 5 }
        public: false
        tags: [{ name: pagerfanta.view, alias: my_view_2 }]

And using then:

{{ pagerfanta(my_pager, 'my_view_1') }}
{{ pagerfanta(my_pager, 'my_view_2') }}

The easiest way to render pagerfantas (or paginators!) ;)

Basic CSS for the default view

The bundles comes with basic CSS for the default view so you can get started with a good paginator faster. Of course you can change it, use another one or create your own view.

<link rel="stylesheet" href="{{ asset('bundles/whiteoctoberpagerfanta/css/pagerfantaDefault.css') }}" type="text/css" media="all" />

Configuration

It's possible to configure the default view for all rendering in your configuration file:

white_october_pagerfanta:
    default_view: my_view_1

Making bad page numbers return a HTTP 500

Right now when the page is out of range or not a number, the server returns a 404 response by default. You can set the following parameters to different than default value to_http_not_found (ie. null) to show a 500 exception when the requested page is not valid instead.

// app/config/config.yml
white_october_pagerfanta:
    exceptions_strategy:
        out_of_range_page:        ~
        not_valid_current_page:   ~

More information

For more advanced documentation, check the Pagerfanta documentation.

Contributing

We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).

If you'd like to contribute code but aren't sure what, the issues list is a good place to start. If you're a first-time code contributor, you may find Github's guide to forking projects helpful.

All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our code of conduct.

Acknowledgements

Pablo Díez ([email protected]) for most of the work on the first versions of this bundle.

This project was originally located at https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle.

License

Pagerfanta is licensed under the MIT License. See the LICENSE file for full details.

whiteoctoberpagerfantabundle's People

Contributors

andreybolonin avatar antoinelemaire avatar antonioperic avatar aramalipoor avatar bobvandevijver avatar eloipoch avatar etheriq avatar gromnan avatar helios-ag avatar inoryy avatar javiereguiluz avatar jeroennoten avatar johnwards avatar loicmobizel avatar makasim avatar mbabker avatar mitjade avatar mynameisbogdan avatar ornicar avatar pablodip avatar payter avatar phibo23 avatar quent-in avatar richsage avatar sampart avatar skadabr avatar spacepossum avatar sstok avatar stof avatar weaverryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whiteoctoberpagerfantabundle's Issues

Error with param in PagerfantaExtension at line 73

Hello,
I updated your bundle and Symfony (2.0.6) and now i encounter an error with PagerfantaExtension.php :

An exception has been thrown during the rendering of a template ("Warning: array_merge(): Argument #2 is not an array in ............../vendor/bundles/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php line 73")

It seems $request->attributes->get('_route_params') at line 73 is not an array ... (I didn't debug more)
I did a quick and dirty patch like this :
if(is_array($request->attributes->get('_route_params')))
$options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params'));
else
$options['routeParams'] = $request->query->all();

But I don't know consequences ...

Any ideas ?

page parameter as a GET string

Is there a way to use pagerfanta and generate urls with get parameters? Like:

/my/nice/route?page=2

My controller by now is:


    /**
     * homepage
     *
     * @Route("/{_locale}/voices",
     *   name="blog_homepage",
     *   defaults={"page"=1},
     *   requirements={"page": "\d+"}
     * )
     * @Template
     *
     * @return array|\Symfony\Component\HttpFoundation\Response
     */
    public function homepageAction()
    {
        .....
    }

Missing translation for Bootstrap3 template

When using the twitter_bootstrap3_translated template, an sr-only class is added to the current page with the content (current). This content is not translated into the various languages.

Example:

When I use this in my Twig template:

{{ pagerfanta(pager, 'twitter_bootstrap3_translated') }}

I get this HTML (my app uses Dutch locale settings):

<ul class="pagination">
    <li class="prev disabled"><span>← Vorige</span></li>
    <li class="active"><span>1 <span class="sr-only">(current)</span></span></li>
    <li><a href="/action/?page=2">2</a></li>
    <li class="next"><a href="/action/?page=2">Volgende →</a></li>
</ul>

As you can see the (current) bit is not translated.

Bug when _route_params not an array

In PagerFantaExtension.php, line 73, the code says:

$options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params'));

This will generate an exception when the second parameter to the array_merge() is not an array.

Replace with:

if (is_array($request->attributes->get('_route_params'))){
    $options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params'));
 }else{
    $options['routeParams'] = $request->query->all();
 }

Support of subrequests

When building the route in the Twig extension, you use the current request to get the route. this fails for subrequests (e.g. $this->forward() or {% render %}) and ESI requests (e.g. {% render with {}, {'standalone': true} %}) as in this cases you don't use the master request containing the true route but an _internal route that should not be available to the end-user but only to the proxy cache (or not at all if you don't use ESI).
There is no way to solve this for ESI as only the cache knows about the main request, and so giving the route explicitly is needed (which is already supported). However, this can be solved for subrequests. See the implementation I wrote for KnplabsPaginatorBundle

Page 0 when no results

When i have 0 results, the pager shows page 0.. Using the DoctrineORMadapter as wel as the arrayadapter.

Am I using it wrong, or have i found a bug?:-)

HTML generated:

<nav>
<span class="disabled">Previous</span>
<span class="current">1</span>
<a href="/products/ebooks/0">0</a>
<span class="disabled">Next</span>
</nav>

PHP code used:

 $em = $this->getDoctrine()->getManager();
        $rep = $em->getRepository('GrenslandBundle:Product');
        /* @var $rep \Doctrine\ORM\EntityRepository */
        $qb = $rep->createQueryBuilder('u');
        $qb->where('u.deleted = 0');

        $filters = array();

        if (($cat = $this->getRequest()->query->get('cat'))) {
            $qb->where('u.categoryId = :CAT')->setParameter(':CAT', $cat);
            $filters['Category'] = $em->find('GrenslandBundle:Product\Category', $cat)->getName();
        }


        $paginator = new \Pagerfanta\Pagerfanta(new \Pagerfanta\Adapter\DoctrineORMAdapter($qb));
        try {
            $paginator->setCurrentPage($page);
        } catch (\Pagerfanta\Exception\NotValidCurrentPageException $e) {
            return $this->redirect($this->generateUrl('firstclass_admin_product_index', array('page' => 1)));
        }

No parameter added to other page links

Hi, can't explain why but no page={number} parameter is added to the links to other pages. So that any page number clicked always returns you the first page. But the indicated number of items are selected. Any help would be appreciated.

PagerfantaExtension problem when using JMSI18nRoute

I am using WhiteOctoberPagerfantaBundle inside AdmingeneratorGeneratorBundle. When enabling the JMSI18nRouteBundle, it produces the following error:

Fatal error: Call to a member function compile() on a non-object in /Users/me/Projects/Web/htdocs/BikecityGuide/website/vendor/bundles/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php on line 74

Must have something to do with the prefix of the I18n route, but I could not figure it out.
de__RG__Bcg_AdminBundle_User_list ANY /de/admin/user/
en__RG__Bcg_AdminBundle_User_delete ANY /admin/user/{pk}/delete

I am on branch symfony2.0.

Feature results per page

Hi all,

what is the bundle propose the results per page feature ?

i dont see it

maxPerPage: [1, 5, 10, 50, 100]
defaultMaxPerPage: 50

something like that, and the view for that ?

thx for replies

[RFC] Redirect to last available page strategy

This is follow up of #60.

I want create redirect to last available page when trying open non-existent page (OutOfRangeCurrentPageException). Currently I've code like this

<?php

namespace Metal\ProjectBundle\Pagerfanta\EventListener;

use Pagerfanta\Exception\NotValidCurrentPageException;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class HandleOutOfRangeCurrentPage implements EventSubscriberInterface
{
    private $router;

    public function __construct(UrlGeneratorInterface $router)
    {
        $this->router = $router;
    }

    /**
     * @param GetResponseForExceptionEvent $event
     */
    public function onException(GetResponseForExceptionEvent $event)
    {
        $rootException = $exception = $event->getException();

        do {
            if ($exception instanceof OutOfRangeCurrentPageException) {
                preg_match('/"(\d+)"$/', $exception->getMessage(), $matches); // this hack can be easy removed: create field "maxAvailablePage" in exception class
                $maxPage = $matches[1];
                $request = $event->getRequest();
                $url = $this->router->generate(
                    $request->attributes->get('_route'),
                    array_merge(
                        $request->attributes->get('_route_params'),
                        $request->query->all(),
                        array('page' => $maxPage) // we have hardcoded page parameter name here
                    ),
                    true
                );

                $event->setResponse(RedirectResponse::create($url, 301));

                return;
            }

            if ($exception instanceof NotValidCurrentPageException) {
                $event->setException(new NotFoundHttpException('Page Not Found', $rootException));
                return;
            }
        } while ($exception = $exception->getPrevious()); // Twig wraps actual exception into his own
    }

    /**
     * {@inheritDoc}
     */
    public static function getSubscribedEvents()
    {
        return array(
            KernelEvents::EXCEPTION => array('onException', 512)
        );
    }
}

As you can see from code above, main problem is that we cann't dehardcode parameter for page name. Has anybody any suggestions for how to deal with it?

I think, that we can create method like Form::handleRequest, something like $pagerfanta->handleRequest($request, 'nameOfPageParameter') and then use this parameter on route generation.

[DoctrineORM] Cannot count query which selects two FROM components, cannot make distinction

Hi,

I need to join non-related entities to perform some filtering and sorting.

I've done this by $qb->leftJoin('AcmeDemoBundle:Tag', 't', Expr\With, 'q.tag = tag.name').

However, this causes Cannot count query which selects two FROM components, cannot make distinction error.

While googleing I've found that KnpPaginatorBundle has a solution for this.

Is there any way I could force similar behaviour with WhiteOctober/PagerFanta?

Slow query times

I have a db wit a lot of items, +230.000.

When I use PagerFanta it gives me very slow query times because it seems that it have to run trough all items on each page load.

You can see on the attached image what I mean.

db-query

Is this true?

Single id is not allowed on composite primary key

Hi,
i have problem fetching data with Pagerfanta and composite keys

Here is specification of my table, I am wondering is it possible to use composite keys and pagerfanta?

Thnx

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="Bundle\ApiBundle\Entity\Item2Term" table="item2_term" repository-class="Bundle\ApiBundle\Repository\Item2TermRepository">
   <indexes>
     <index name="item2_term_FI_1" columns="item2_id"/>
      <index name="item2_term_FI_2" columns="term_id"/>
      <index name="item2_term_FI_3" columns="sf_guard_user_id"/>
    </indexes>
    <id name="item2" association-key="true"/>
   <id name="term" association-key="true"/>
   <id name="sfGuardUser" association-key="true"/>
   <field name="city" type="string" column="city" length="50" nullable="true"/>
  <one-to-one field="sfGuardUser" target-entity="SfGuardUser">
  <join-columns>
    <join-column name="sf_guard_user_id" referenced-column-name="id"/>
  </join-columns>
</one-to-one>
<one-to-one field="term" target-entity="Term">
  <join-columns>
    <join-column name="term_id" referenced-column-name="id"/>
  </join-columns>
</one-to-one>
<one-to-one field="item2" target-entity="Item2">
  <join-columns>
    <join-column name="item2_id" referenced-column-name="id"/>
  </join-columns>
</one-to-one>
  </entity>
</doctrine-mapping>

Make a Factory service for Adapter and Pagination class

How about to make a service as the wrapper class ?

native

$pagination = new Pagerfanta(new DoctrineORMAdapter($queryBuilder));
$pagination->setMaxPerPage($maxPerPage);

service

$pagination = $this->container->get('white_october_pagerfanta.doctrine_orm')
    ->setQueryBuilder($queryBuilder)
    ->getPagination()
;

$pagination->setMaxPerPage($maxPerPage);

or with setArguments

$pagination = $this->container->get('white_october_pagerfanta.doctrine_dbal')
    ->setArguments($queryBuilder, $countQueryBuilderModifier)
    ->getPagination()
;

$pagination->setMaxPerPage($maxPerPage);

and default service configuration

#app/config/config.yml;
white_october_pagerfanta:
    default_adapter: doctrine_orm

using

$pagination = $this->container->get('white_october_pagerfanta.default')
    ->setArguments($queryBuilder)
    ->getPagination()
;

$pagination->setMaxPerPage($maxPerPage);

etc...

Duplicate content

Hi,

First, thank you all for this nice bundle.
I faced a problem of duplicate content with the pager. I'v got two routes about product listings because of SEO beliefs (example below).

product_home:
   pattern: /products/
   methods: GET
   defaults:
      _controller: ProductBundle:plop:index
      page: 1

product_home_page:
   pattern: /products/page-{page}
   methods: GET
   defaults:
      _controller: ProductBundle:plop:index
      page: 1

As you can guess /products/ and /products/page-1 display the same page and so, are seen as duplicate content.
I've solved it by passing the product_home route as argument to the Pagerfanta Twig extension and use this to generate the route for first page.
Does it worth a pull request or is it too specific to integrate this possibility into the bundle ?

_route_params returns null in edge case

Similar to Issue #32 (but using the correct version of symfony).

I'm finding in Symfony 2.2 that there is a circumstance where $request->attributes->get('_route_params') does in fact return null. (and the merge error happens).

If rendering a fragment in twig, which calls a controller (and that controller ends up calling this extension), then the request attributes in that situation don't have a '_route_params' attribute set.

I'm guessing the break happened around this time:
http://symfony.com/blog/new-in-symfony-2-2-the-new-fragment-sub-framework

It think that the check for the 'internal' route is incorrect and an exception should be (legitimately) thrown.

The check should be against the 'strategy' option?

Composer version dependency broken

v1.0.1 of this bundle has requirements of 1.0.* of library, and configures " TwitterBootstrap3View.php" as available view in v1.0.1 of bundle version.

But... 1.0.0 of lib doesn't have such class at all.

v1.0.1 version of this bundle should depend on >=1.0.1 of library not v1.0.*

And becouse of adding new features (bootstrap 3 support) even semantic versioning is not inline, as both versions should be 1.1.0

array_merge issue in renderPagerFanta method

I face this exception in my SF 2.0.14 install :

An exception has been thrown during the rendering of a template ("Warning: array_merge(): Argument #2 is not an array in /home/bruno/www/Bruno/Projects/Sf2/vendor/bundles/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php line 77")

The problem is caused by $request->attributes->get('_route_params') as in my project it returns null.

previous_message no effect

Hi,

I can't change the previous message.. No problem with next it change perfectly but previous...

pagerfanta.view.test:
    class: Pagerfanta\View\OptionableView
    arguments:
        - @pagerfanta.view.twitter_bootstrap
        - { previous_message: &#10096, next_message: &#10097 }
    public: false
    tags: [{ name: pagerfanta.view, alias: test }]

Did i forget something ?

new stable tag?

A new stable tag would come handy after all the deprecation removal patches commited in the last days. Thanks! :D

What is the best way to use it with entity repository ?

Forgive my ignorance, but what is the best way to use it with entity repository ?

Pass the pager fanta params to repository method, pass the adapter object or keep it in the controller and just get the query from repository.

Thanks for your advices.

Improve the retrieving of the route parameters for Symfony 2.1

Currently, Pagerfanta compiles the route to find the parameters needed to generate the url. This is both inefficient (getRouteCollection triggers the routing loaders) and incompatible with both existing *I18nRoutingBundle (as they do some magic when generating the url and matching the route which is bypassed by this bundle).
In the master branch, Symfony now defines a _route_params atribute in the Request containing the attributes used in the url. It would be a good idea to create a branch (or a tag) dedicated to the Symfony 2.0 compatibility and then to clean the code in the master branch for Symfony master.

problem with select count and sum with group by

Hi,
I have a problem with a query with count and sum and a group by.

$query->select(array('a', 'SUBSTRING(a.dateAppel, 1, 10) as groupby', 'COUNT(a) as nbappel', 'SUM(a.duration) as duree'))
                    ->from('A:AB', 'a')
                    ->where('a.dateAppel > \''.$filterAppelPoste->getDateStart().' 00:00:00\'')
                    ->andWhere('a.dateAppel < \''.$filterAppelPoste->getDateEnd().' 23:59:59\'')
                    ->groupBy('a.user')
                    ->addGroupBy('groupby')
                    ->add('orderBy', 'groupby ASC');

for debug i use

            $result = $query->getResult();
            \Doctrine\Common\Util\Debug::dump($result);

In this debug mode i find duree and nbappel with the right value.

my pagerAction

public function pagerAction($page , HttpFoundation\Request $request, $queryBuilder)
    {
        $pagerDoctrineAdapter = new Pagerfanta\Adapter\DoctrineORMAdapter($queryBuilder);
        $pager = new Pagerfanta\Pagerfanta($pagerDoctrineAdapter);
        $pager->setMaxPerPage($this->container->getParameter('lig_app.pager.max_per_page'));

        try
        {
            $pager->setCurrentPage($page);
        }
        catch( Pagerfanta\Exception\NotValidCurrentPageException $e)
        {
            throw new HttpKernel\Exception\NotFoundHttpException();
        }

        return $pager;
    }

and my view

 {% for entity in pager.currentPageResults %}
                    <tr>
                            <td>{{ entity[0].user.username }}</td>
                            <td>{{ entity[0].destination }}</td>
                            <td>{{ entity.duree }}</td>
                            <td>{{ entity.nbappel }}</td>
                            {% set translationtype =  'view.asterix.appelposte.list.'~entity[0].typeappel|lower %}
                            <td>{{ translationtype|trans({}, 'LIGAsterixBundle') }}</td>
                            <td>{{ entity.groupby }}</td>
                    </tr>
                {% endfor %}

In my view
"entity.duree" take the value on my first entity on group by
"entity.nbappel" always equal 1

I think Pager does not take the group by

Thx for your reply

See ya

Providing tags

@richsage @pablodip can you provide tags in your bundle.

This will be a good practice to avoid issues when using this bundle in production environment.

fix bug when routeName is passed as params into pagerfanta twig function

hi
in this situation :

{% if pager.haveToPaginate %}
    {{ pagerfanta(pager, 'twitter_bootstrap3_translated', {'routeName': 'search_annonces_1'},{'routeParams' : { 'v': 'keyword'  }}) }}
{% endif %}

we suppose inject keyword in pagination such a params route like this
/q=keyword&l=
but pagerfanta still generate route as
/q=&l=

this happen when routeName is passed as params into pagerfanta twig function

how to install

I really hate it when readmes are not doing what they promise :-)

Add Pagerfanta and WhiteOctoberPagerfantaBundle to your vendors:

git submodule add http://github.com/whiteoctober/Pagerfanta.git vendor/pagerfanta

ok, let's go...

E:\Github\symfony-standard>git submodule add http://github.com/whiteoctober/Pagerfanta.git vendor/pagerfanta
fatal: Not a git repository (or any of the parent directories): .git

Why bundle developers always asume people are pulling symfony standard from git ?
Have you guys ever thought about the fact most people just download the release on symfony.com and there is not .git directory or anything like that ?

Why not simply creating a download that we can extract in vendors, and only have to set autoload and the kernel ?

It even doesn't work when you download the package from git here, as face it...

git submodule add http://github.com/whiteoctober/Pagerfanta.git vendor/pagerfanta
git submodule add http://github.com/whiteoctober/WhiteOctoberPagerfantaBundle.git vendor/bundles/WhiteOctober/PagerfantaBundle

This are two locations (vendor/pagerfanta and vendor/bundles/WhiteOctober/PagerfantaBundle), and when you download the package you only have a collection of files that should go into where ???

And it is more odd some bundles depend on this one, while you are not able to install it anyway.

You guys are not making it easy for symfony 2 users to use your bundle, that's for sure.

Tag a new release

Hey!
Is there a plan for a new release of the bundle? It'd be great to have my project (based on Sylius) to use a stable version instead of dev-master :)

Fatal error: Class 'WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle' not found in /var/www/AceAdmin/app/AppKernel.php on line 23

Hi

I saw all issues tracker for my issue but i couldn't get proper procedure to solve my problem.

Symfony version am using is 2.1.*
I added folder manually in my vendor
1. /vendor/pagerfanta => for pagerfanta folder got from https://github.com/whiteoctober/Pagerfanta
2. /vendor/bundles/WhiteOctober/PagerfantaBundle/WhiteOctoberPagerfantaBundle
file got(download) from https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle

i add two line manually in autoload.php
$loader->add('WhiteOctober\PagerfantaBundle', DIR.'/../vendor/bundles');
$loader->add('Pagerfanta', DIR.'/../vendor/pagerfanta/src');

Then i added namespace in AppKernel.php
$bundles = array(
//.....
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
);

But am getting this

Fatal error: Class 'WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle' not found in /var/www/AceAdmin/app/AppKernel.php on line 23

error

So i need proper method(steps) to install WhiteOctoberPagerfantaBundle in symfony 2.1

If i get quick reply it will helpfull for me.

Thanks for ur help in advance
Sivavin

The link to other pages is not displayed properly

When using the following code in the template, the output is only the previous and next link but disabled (as if there were only one page):

{{ pagerfanta(paginator, 'default') }}

I get the correct rendering when using this code to force counting the results:

{% set results = paginator.nbResults %}
{{ pagerfanta(paginator, 'default') }}

Btw, the CSS provided for the default view (in the comment) requires to enclose the view in a div with the pagerfanta class, which is not documented anywhere.

new tag 1.0.2

Hey Pablo,

Could you please tag the latest version? We use 1.0.* in our composer.json?

Thnx :)

PagerFantaBundle dev-master requires pagerfanta 1.0.*

Hi,

We use PagerFantaBundle, and after a composer update we got this error : "Class 'Pagerfanta\View\TwitterBootstrap3View' not found"

It seems that PagerFantaBundle requires Pagerfanta 1.0.* but this version doest not include TwitterBootstrap3View.

Thanks !

The function "pagerfanta" does not exist

Hello,

I'me used to use PagerFanta and this bundle on SF2 projects, and I know want to use it in Symfony 2.1.

I install it with composer adding this line in my composer.json file and update my project :

"white-october/pagerfanta-bundle": "dev-master"

The I try to display my pager (everything works fine in the controller, with the Pagerfanta\Pagerfanta class).

{{ pagerfanta(pager) }}

And I get this error :

The function "pagerfanta" does not exist in /path/to/my/template.html.twig at line 26 

Do I get the installation wrong ? (I'm quite new to Composer)

render bug

An exception has been thrown during the rendering of a template 
("Warning: array_merge(): Argument #2 is not an array in
[my_path]/symfony/vendor/bundles/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php line 73")
in [my_view].html.twig at line 17.

in [my_view].html.twig at line 17 I have this code:

 {{ pagerfanta(searchResults) }}

and in Pagerfanta at line 73:

 $options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params'));

unfortunately I haven't this var ('_route_params'). Might be you should tj set default option for 'get' method
for example:

$options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params', array()));

Managing URL should really be easier

Let's say we have this url patterns :

/videos
/videos/page1
/videos/page2...

First, we need two routes, and we typically set a default page=1 for the first one.
But then, we have a SEO problem (duplicate content), the first two url match the same content. So, additionally to our two routes, we add a 301 redirection for "/videos/page1" to "/videos".

I really think this whole thing should be simpler, from Symfony routing system or the bundle, i don't know. Or maybe i'm missing something to do that ?

I would be really interested in having some feedbacks on how you manage your urls for this kind of common url patterns.

Problem with list.html.twig template

I have a problem displaying the records. After the initial configuration:

Item "isSelected" for "" does not exist in "WhiteOctoberAdminBundle::default/list.html.twig" at line 93

Previous and Next messages with Bootstrap 3 view

What is the simplest way to set Bootstrap 3 template as default and provide custom strings for next / previous?

If I use the OptionableView to pass in previous & next messages I loose the Bootstrap output.

error: Warning: array_merge(): Argument #2 is not an array

I am getting this error:

An exception has been thrown during the rendering of a template ("Warning: array_merge(): Argument #2 is not an array in /usr/local/zend/apache2/htdocs/ck/vendor/bundles/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php line 73") in CkAdminBundle:Widget:index.html.twig at line 16.

It appears the master version does not work with symfony 2.0.6

Should I download teh branch symfony2.0?

how to add a custom twig template ?

I would like to override the default template, and custom it with a template.html.twig file in my root views folder

Can't find anything on internet about it...

Polish translation bug

In Polish translation file (Resources/translations/pagerfanta.pl.xliff), translations for next and previous are inversed.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.