Según tus recomendaciones:
application/config/pagination.php
Código PHP:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
function pagination($limite)
{
$config = [
'use_page_numbers' => true, # Salta por unidad el vez de por $limite
'base_url' => base_url('blog/home'),
'first_url' => base_url('blog/home/1'),
'total_rows' => $this->db->get('post')->num_rows(),
'per_page' => $limite,
'num_links' => 5, #Páginas adyacentes visibles
'first_link' => 'Primero',
'last_link' => 'Ultimo',
'next_link' => 'Siguiente',
'prev_link' => 'Anterior',
'full_tag_open' => '<ul class="pager">',
'full_tag_close' => '</ul>',
'cur_tag_open' => '<li><span>',
'cur_tag_close' => '</span></li>',
'num_tag_open' => '<li>',
'num_tag_close' => '</li>',
'first_tag_open' => '<li>',
'first_tag_close' => '</li>',
'last_tag_open' => '<li>',
'last_tag_close' => '</li>',
'next_tag_open' => '<li class="next">',
'next_tag_close' => '</li>',
'prev_tag_open' => '<li class="previous">',
'prev_tag_close' => '</li>',
'display_pages' => false, #Oculta las páginas
'first_link' => false, #Oculta primero
'last_link' => false, #Oculta ultimo
];
return $config;
}
mi_controlador.php
Código PHP:
public function home($pagina = ''){
$data = $this->data;
$data['imagen'] = base_url('clean_blog/img/'.__FUNCTION__.'-bg.jpg');
$limite = 2;
$inicio = $pagina ? --$pagina*$limite : 0 ;
$this->load->library('pagination');
$this->pagination->initialize($config);
$this->db->order_by('id','desc');
if ($inicio !== false && $limite !== false) $this->db->limit($limite, $inicio);
#$data['filas'] = $this->db->get('post',$limite,$inicio)->result_array();
$data['filas'] = $this->db->get('post',$limite,$inicio)->result();
views('blog',['head','nav','header',__FUNCTION__,'footer'],$data);
}
Código:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: config
Filename: controllers/blog.php
Line Number: 35
Backtrace:
File: C:\xampp\htdocs\anhida\application\controllers\blog.php
Line: 35
Function: _error_handler
File: C:\xampp\htdocs\anhida\index.php
Line: 292
Function: require_once