Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Knp分页捆绑包不在同一重新排序的视图上显示分页_Php_Symfony 2.1_Symfony 3.1_Knppaginator_Knppaginatorbundle - Fatal编程技术网

Php Knp分页捆绑包不在同一重新排序的视图上显示分页

Php Knp分页捆绑包不在同一重新排序的视图上显示分页,php,symfony-2.1,symfony-3.1,knppaginator,knppaginatorbundle,Php,Symfony 2.1,Symfony 3.1,Knppaginator,Knppaginatorbundle,我有{knp_pagination_render(pagination1)}在查看InfCustumersBundle:Faktura:indexoryginal.html.twig 此代码显示paginarion: public function indexoryginalAction(Request $request) { $em = $this->getDoctrine()->getManager();

我有
{knp_pagination_render(pagination1)}
在查看
InfCustumersBundle:Faktura:indexoryginal.html.twig

此代码显示paginarion:

public function indexoryginalAction(Request $request) {              
            $em = $this->getDoctrine()->getManager();
            $req = $em->getRepository('...:Faktura');
            $qb = $req->createQueryBuilder('p');
            $search = $qb
                        .
            .
                    ->getQuery();              
           $form = $this->createFormBuilder()
               .
           .
                ->getForm();
        $paginator = $this->get('knp_paginator');
        $pagination1 = $paginator->paginate(
                $search, $request->query->get('page', 1)/* page number */, 5/* limit per page */
        );

        return $this->render('InfCustumersBundle:Faktura:indexoryginal.html.twig', array(
                    'pagination1' => $pagination1,
                    'form' => $form->createView()
        ));
这很好,但下面的代码不显示分页标记。只有前3项。我哪里出错了

public function indexAction(Request $request, $type = 1) {

        $data = array();
        $form = $this->createFormBuilder()
                .
        .   
                ->getForm();
        if ($request->isMethod('GET')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();
                    $name = ($data['for'] == 'name' ? true : false);
                if ($name) {
                    return $this->Name($form);
                } 
            }          
                return $this->redirect($this->generateUrl('faktura_oryginal', array(
                                    $this->get('session')->getFlashBag()->add('error', 'error')
                )));          
        }

protected function Name($form) {

        $em2 = $this->getDoctrine()->getManager();
        $req = $em2->getRepository('InfCustomersBundle:Faktura');
        $qb = $req->createQueryBuilder('p');

        $query2 = $qb
                .
                .
                ->getQuery();

        $entities2 = $query2->getResult();
        if ($entities2) {

            $paginator = $this->get('knp_paginator');
            $request = $this->get('request_stack');
            //  $request = $this->getRequest();
            $pagination1 = $paginator->paginate(
                    $query2, $request->getCurrentRequest()->query->get('page', 1)/* page number */, 3/* limit per page */
            );          
                return $this->render('InfCustumersBundle:Faktura:indexoryginal.html.twig', array(
                            'pagination1' => $pagination1,
                            'form' => $form->createView()
                ));          
        } else {
                return $this->redirect($this->generateUrl('faktura_oryginal', array(                               $this->get('session')->getFlashBag()->add('error', 'error')
                )));         
            }
        }
    }
我找到了解决办法

我改变了:

$entities2 = $query2->getResult();
        if ($entities2) {

现在一切顺利

    $pagination1 = $paginator->paginate(
            $query2, $request->getCurrentRequest()->query->get('page',1),25);
    if (count($pagination1) > 0) {