Pagination Kohana

File ROUTE (/application/bootstrap.php)

Route::set('list', 'list(/<slug>(/<page>))')
        ->defaults(array(
            'directory'     => 'frontend',
            'controller'    => 'company',
            'action'        => 'list',
));

File CONTROLLER (/application/classes/controller/frontend/company.php)

public function action_list(){        
        $slug = $this->request->param('slug');
        $page = $this->request->param('page');
       
        if($page==""){ $page = 1; }
       
        $rs_category = ORM::factory('company_category', array('slug' => $slug));        
        $total  = $rs_category->lsCompany->count_all();        
       
        $items_per_page = 30;
        $off = ($page-1)*$items_per_page + ($page-1);
       
        $ls_company = $rs_category->lsCompany->offset($off)->limit($items_per_page)->find_all();
       
        $view = View::factory('frontend/company/list');
        $view->set("ls_company", $ls_company);
        $view->set("total", $total);
        $view->set("items_per_page", $items_per_page);
        $view->set("route_slug", "list/".$slug);
       
        $this->template->set('content', $view);
}

File VIEW (/application/views/frontend/company/list.php)

<ul>
<?php
    foreach($ls_company as $rs_company) {
        ?>
        <li><a href="/c/<?php echo $rs_company->slug; ?>"><?php echo $rs_company->name; ?></a></li>
        <?php        
    }
   
    $npage =  $total/$items_per_page;
    for($i=1; $i<$npage-1; $i++){
        ?>
        <a href="/<?php echo $route_slug;?>/<?php echo $i; ?>"><?php echo $i; ?></a>
        <?php        
    }
   
?>
</ul>
post-author