Pagination does not work

Hugilore111

Member
Hi
I have not worked pagination
tell me where the error

Route
Code:
<?php
class Example_Route_Prefix_Example implements XenForo_Route_Interface
{
 
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        return $router->getRouteMatch('Example_ControllerPublic_Account', 'account/example', 'forums');
    }
   }

Controller
Code:
    $viewParams =array(
   
       
           'thingsPerPage'=>50,
           'page'=>5,
           'totalThings'=>10
         
        );
template

Code:
<xen:title>Page navigation example{xen:helper pagenumber, $page}</xen:title>
<xen:pagenav link="account/example" page="{$page}" perpage="{$thingsPerPage}" total="{$totalThings}" />
 
Last edited:
Model
Code:
    public function Example($Example,array $fetchOptions)
    {
        $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);
     
        return $this->_getDb()->fetchAll($this->limitQueryResults('
            SELECT xf_example.*
            FROM xf_example_ex
            INNER JOIN xf_user ON xf_user.user_id = xf_example_ex.user_id
            WHERE (' . $Example . ') = xf_example_ex.id_ex
         ORDER BY xf_user.username DESC
        ', $limitOptions['limit'], $limitOptions['offset']
    ));
    }
Controller
Code:
<?php
class Example_ControllerPublic_Account extends XFCP_Example_ControllerPublic_Account
{
 
 
    public function actionExample()
    {
$thingsPerPage = XenForo_Application::get('options')->thingsPerPage;
$page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
$Example = $ModelExample->Example($Example,array('perPage' => $thingsPerPage, 'page' => $page));
$viewParams =array(
   
         
           'thingsPerPage'=>$thingsPerPage,
           'page'=>$page,
           'totalThings'=>count($Example)
         
        );
return $this->_getWrapper(
                'account', 'example',
                $this->responseView('Example_ViewPublic_Account_Example', 'example',$viewParams)
            );
 
    }
 
You must create another function to count the things from your database table. Then you call it to the controller and register its variable. See the examples posted by Bob in that other thread that you posted about this.
 
Top Bottom