Problems with Paging in SLIM with Pager

1

How to make page change using Pear-Pager in SLIM Framework?

The code for router is:

    $app->get('/imoveis(/:pg)', function($pg = '') use($app) {
    $imoveis = array('casa 1', 'casa 2', 'casa 3', 'casa 4', 'casa 5', 'casa 6', 'casa 7', 'casa 8', 'casa 9', 'casa 10');
    $params = array(
        'mode' => 'Jumping',
        'perPage' => 3,
        'delta' => 4,
        'itemData' => $imoveis,
        'append' => false,
        'path' => site_url().'imoveis/' ,
        'fileName' => '%d',
        'altNext' => 'Próximo',
        'nextImg' => '>>Próximo',        
    );
    $pager = Pager::factory($params);
    $data = $pager->getPageData();
    $links = $pager->getLinks();

    $dados = array(
        'titulo' => 'Nossos imóveis',
        'pagina' => 'imoveis',
        'menu_hover' => 3,
        'dados' => $data,
        'links' => $links,
    );

    $app->render('layout.php', $dados);
});

and that of view is:

<?php 
foreach ($dados as $item):
    echo $item->codigo.'<br />';
endforeach;
echo $links['all'];
?>

When I click on the page number it simply changes the URL but the result remains the same.

    
asked by anonymous 20.02.2014 / 17:52

1 answer

1

Try setting "currentPage" to params :

'currentPage' => $pg,

It should be conflicting with how the slim picks up the data.

See the complete list of parameters that you can define in doubt.

    
21.05.2014 / 23:58