0
I have problems in a pagination with searching via form in Zend Framework 1.
There is a method in the model that makes a query with Where to bring the result as the search done, and the pagination if it is done without session works only the first page, because the others do not bring the results as filter.
After days of searching and still no solution, I saw that I can really try to use the session to try to remedy this problem, but I don’t understand how to apply this.
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 must be something wrong that I do not know =\
Anyway, could someone help me?
I really handled it with Session, but it’s good this one of yours, and who knows who now will get easier one day. Because it was very difficult to find any practical solution to this. Thank you!
– phpricardo
I had some problems with the use of the session... because when I delete the record it is not disappearing, until pq to using the forward as I posted another link there. @Lucas did not understand this application of yours without.
– phpricardo
I didn’t understand this application on top of what I did, you still used the $session search?
– phpricardo
No. The search comes by parameter (GET or POST), using
getParam()
. Then send this search to view (assign) and pass it by parameter to the script of pagination.– Lucas
Malz, but I’m not getting it right. =\
– phpricardo
Your search comes for GET? You have a pagination.phtml?
– Lucas
Via POST and yes I have pagination.phtml -- <? php if (isset($this->next)): ? > <a href="<? php echo $this->url(array('page' => $this->next)); ? >" Aria-label="Next" > <span Aria-Hidden="true">»</span> </a>
– phpricardo
Then, go through parts as I wrote in the reply, going from one script to the other, until you receive there in pagination.phtml and concatenate in the link
– Lucas
Let’s go continue this discussion in chat.
– phpricardo