Zend_Session and Zend_Pagination with form search

0

I'm having problems with paging with form lookup in Zend Framework 1.

There is a method in the model that does a query with where to bring the result according to the research done, and pagination if done without session only works the first page, since the other does not bring the results as filter. >

After days searching and still no solution, I saw that I can actually try to use the session to try to fix this problem, but I do not understand how to apply it.

I have the following controller:

public function consultarAction()
    {

        $setor = $this->_getParam('setor');

        $modLotacao = new Sca_Model_Lotacao('sca');

        $resultado = $modLotacao->getConsultaTelefones($setor);

        $busca = new Zend_Session_Namespace($resultado);

        if ($this->_request->isPost()) {
            $busca->unsetAll();
            $busca->busca = $this->_request->getPost();
        }

        $paginator = Zend_Paginator::factory($resultado($busca->busca));
        $paginator->setItemCountPerPage(5);
        $paginator->setPageRange(7);
        $paginator->setCurrentPageNumber(intval($this->_request->getParam('pagina', 1)));

        $this->view->paginator = $paginator;    

    }

This is returning me error, but really should something is wrong that I do not know = \

Anyway, could anyone help me?

    
asked by anonymous 11.02.2015 / 17:15

1 answer

1

I've already solved this filtering problem in paging without session , just passing parameters. Here's the solution:

Controller

Get the list and mount the paginator :

$paginator = Zend_Paginator::factory($lista);
$paginator->setItemCountPerPage(12)->setCurrentPageNumber($this->getParam('p', 1));
$paginator->setPageRange(5);
$this->view->assign('lista', $paginator);

Send the search to view also:

$this->view->assign('busca', $this->getParam('busca'));

View of action

Print the page layout, passing the search in the 4th parameter:

echo $this->paginationControl($this->lista, 'Sliding', 'pagination.phtml', array('busca' => $this->busca));

View of pagination

In view of pagination (usually pagination.phtml ), it receives the parameter with the filters:

$filtros = $this->busca

... and concatenate them in the links of pagination.

    
11.02.2015 / 19:49