Git Product home page Git Product logo

Comments (6)

pablodip avatar pablodip commented on June 8, 2024

What's the state of this? Ideas? Ping @stof

from whiteoctoberpagerfantabundle.

justinhilles avatar justinhilles commented on June 8, 2024

I have been looking at this for 2 hours and cannot figure out why this wont work
This is in my controller

        $pager = new Pagerfanta(new DoctrineORMAdapter($query));

        try {
            $pager
                ->setMaxPerPage($max)
                ->setCurrentpage($page);

        } catch (OutOfRangeCurrentPageException $e) {

            throw $this->createNotFoundException($e->getMessage());
        }

        return $this->render($template, array('pager' => $pager));

This is in my template

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

This is my response:

ContextErrorException: Warning: array_merge(): Argument #2 is not an array in site/vendor/white-october/pagerfanta-bundle/WhiteOctober/PagerfantaBundle/Twig/PagerfantaExtension.php line 119

Running, i Think , Symfony 2.3

from whiteoctoberpagerfantabundle.

justinhilles avatar justinhilles commented on June 8, 2024

I think i solved my issue, may not apply to everyone. I had a default parameter of page 1 in my route, removing that cleared this up for me

from whiteoctoberpagerfantabundle.

umpirsky avatar umpirsky commented on June 8, 2024

Facing same issue with Symfony 2.3.

I guess $request->attributes->get('_route_params') should be checked with is_array() or against null values before merging arrays.

from whiteoctoberpagerfantabundle.

jpass avatar jpass commented on June 8, 2024

This always happens if we forward to action that later uses pagerfanta, as subrequest has no information about route: symfony/symfony#5804

update:
Added pull request.

update2:
in controller:

$ret = array_merge($request->attributes->all(), 
array(
    // my normal forwarding params
));
return $this->forward('controller:action', $ret);

from whiteoctoberpagerfantabundle.

justinhilles avatar justinhilles commented on June 8, 2024

I ran into this problem again, rendering an embedded controller with pagerfanta in the template, As a temp solution I get the master request current route and pass it to pager fanta:

In Controller:

            $request = $this->container->get('request_stack')->getParentRequest();

            $route = $request->get('_route');

In View:

{{ pagerfanta(pager, 'twitter_bootstrap3', {'routeName' : route }) }}

Working great at the moment, but id like to not have to. But i cant think of a more elegant way to do this

from whiteoctoberpagerfantabundle.

Related Issues (20)

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.