Welcome Guest, Not a member yet? Register   Sign In
Problem with $anchor_class with Pagination class
#1

[eluser]Unknown[/eluser]
Hello, this is my first web project, so my first CI project and my first post in this forums. Also I'm not english speaker, excuse my bad english (and my bad coding :redSmile.

I'm using CI 2.03

I have a problem using the pagination class. When i use it without adding a class all works as expected, links render correctly and show the next results in my table. When I try to use:

Code:
$config['anchor_class'] = 'paginacio';

in order to use ajax to reload only the result table using ajax (getting html) pagination links don't get rendered correctly, i get this:

Code:
<a paginaciohref="http://192.168.1.39/index.php/bancdetemps/missatgeria/1">&gt;</a>&nbsp;&nbsp;

Seen this i tried to modify Pagination.php in this way:

Code:
...
var $query_string_segment = 'per_page';
var $display_pages  = TRUE;
var $anchor_class  = 'paginacio';
...

I get the correct class added to my links and first results and pagination links render correctly, BUT once i jump to other page (2, 3...) and i click again on the first page link (1) i see correctly the 1rst results but pagination links render the 2 page as current page and keep rendering the &lt; link. The original code:

Code:
function missatgeria($prim_param = '', $seg_param = ''){
  $dades['ruta'] = RUTA;
  $dades['menu'] = $this-&gt;menu_lateral();
  $usuari = $this->session->userdata('id_usuari');
  if($usuari){
   $this->output->set_header("Cache-Control: private, no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
   $this->output->set_header("Pragma: no-cache");
   $this->load->helper('url');
   $this->load->helper('date');
   $this->load->library('pagination');
   $config['per_page'] = RES_PAGINA;
   $config['base_url'] = RUTA.'/missatgeria/';
   $segment = $this->uri->segment(3);
   if((!is_numeric($prim_param))&&($prim_param != NULL)){
    $seccio = $prim_param;
    $config['base_url'] = $config['base_url'].$prim_param;
    $config['total_rows'] = $this->Model_bancdetemps->llistat_missatges($usuari, $seccio)->num_rows();
    if($seg_param != ''){
     $config['uri_segment']= 4;
     $segment = $this->uri->segment(4);
    }
    else $segment = '';
   }
   else{
    $seccio = "entrada";
    $config['total_rows'] = $this->Model_bancdetemps->llistat_missatges($usuari, $seccio)->num_rows();
   }
   $dades['bustia'] = $seccio;
   $dades['missatges'] = $this->Model_bancdetemps->llistat_missatges($usuari, $seccio, $config['per_page'],$segment);
   $config['full_tag_open'] = '<p>';
   $config['full_tag_close'] = '</p>';
   $this->pagination->initialize($config);
   $dades['cos'] = $this->load->view('vista_missatges',$dades, TRUE);
  }
  else $dades['cos'] = "Inicia sessiĆ³ per accedir a la missatgeria.";
  if($this->isAjax()) $this->load->view('vista_ajax_missatges',$dades);
  else $this->load->view('vista_bancdetemps', $dades);
}

Thank you for your time and congratullations to Ellislab for this great product (double great being open source).




Theme © iAndrew 2016 - Forum software by © MyBB