Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/01/2017, 08:57
miguelA4
 
Fecha de Ingreso: marzo-2015
Ubicación: Valencia
Mensajes: 132
Antigüedad: 9 años, 1 mes
Puntos: 0
Respuesta: Paginación me da error

Siento no haberme explicado bien.

El tema es una paginación para un blog, encontre un archivo llamado PHPPaging.lib.php, que ya viene todo creado y poniendo esto sólo, te sale la paginación.

Código HTML:
Ver original
  1. <ul class="pagination">
  2.         <?php echo ''.$pagina ->fetchNavegacion(); ?>
  3.         </ul>

Lo de <ul class="pagination" lo puse yo para darle los estilos de bootstrap.
Después en el archivo "PHPPaging.lib.php", sustitui el <a href> poniendo <li>, para que haga la lista.


Código PHP:
Ver original
  1. function do_link ($page, $title = false,$content) { // Función modificada version 2.0
  2.                 $href = str_replace('{n}', $page, $this->linkEstructura);
  3.                 if(!empty($this->linkAgregar)) $href.= $this->linkAgregar;
  4.                 $estilo = $this->estilo;
  5.                 $title = $title === false ? '' : " title=\"$title\"";
  6.                 return "<li><a href=\"$href\"$title$estilo>$content</a><li>";
  7.         }

El problema esta, en que los estilos me los aplica, pero si estoy en la pagina 1, el dos y el siguiente me sale con los estilos, pero el uno me sale fuera de la paginación, ya que no tiene <a href>. Si estuviese en la página 2 seria al reves. Pego el codigo de "fetchNavegacion", por si me podeis guiar un poco (cabe decir que sólo he copiado las lineas de la funcion "fetchNavegacion", el archivo tiene más de 1000 lineas.

Código PHP:
Ver original
  1. function fetchNavegacion () {
  2.                 if($this->done != true) return $this->error(false, "No se puede generar la barra de navegación pues no se ha realizado ninguna paginación"); // version 2.0
  3.                 if(empty($this->linkEstructura)) {
  4.                         $i = array();
  5.                         if(count($this->mantenerURLVar) > 0) define ('MANTENERURLVARS',1); // version 2.0
  6.                         elseif(count($this->quitarURLVar) > 0) define ('QUITARURLVARS',1); // version 2.0
  7.                         $vars = $_GET;
  8.                         if($this->verPost == true) $vars = array_merge($vars, $_POST); // version 2.0
  9.                         foreach($vars as $key=>$val) {
  10.                                 if($key != $this->nombreVariable) {
  11.                                         if(defined('MANTENERURLVARS') and !in_array($key, $this->mantenerURLVar) or defined('QUITARURLVARS') and in_array($key, $this->quitarURLVar)) continue;
  12.                                         $i[] = "$key".(empty($val) ? '' : "=".urlencode($val)); // Modificado version 2.0
  13.                                 }
  14.                         }
  15.                         $i[] = $this->nombreVariable.'={n}';
  16.                         $this->query_string = implode('&amp;',$i); // Modificado version 2.0
  17.                         $this->linkEstructura = 'http://'.trim($_SERVER['HTTP_HOST'], '/').'/'.ltrim($_SERVER['PHP_SELF'], '/').'?'.$this->query_string;
  18.                 }
  19.                 $this->estilo = (!empty($this->linkClase)) ? ' class="'.$this->linkClase.'"' : NULL;
  20.                 $before = $this->paginasAntes;
  21.                 $after = $this->paginasDespues;
  22.                 $pthis = $this->numEstaPagina;
  23.                 $ptotal = $this->numTotalPaginas;
  24.                 $before = (($pthis - $before) < 1) ? 1 : ($pthis - $before);
  25.                 $after = (($pthis + $after) > $ptotal) ? $ptotal : ($pthis + $after);
  26.                 $link_string1 = array(); // version 2.0
  27.                 $link_string2 = array(); // version 2.0
  28.                 $link_string3 = array(); // version 2.0
  29.                 $link_string4 = array(); // version 2.0
  30.                 $link_string5 = array(); // version 2.0
  31.                 if($this->mostrarPrimera !== false and $pthis > $this->paginasAntes+1) { // Modificado version 2.0
  32.                         $link_string1[] = $this->do_link(1,$this->addlinkmsg(1,1,$this->porPagina,1),$this->mostrarPrimera);
  33.                 }
  34.                 if($this->mostrarAnterior !== false and $pthis > 1) { // Modificado version 2.0
  35.                         $link_string1[] = $this->do_link(($pthis-1),$this->addlinkmsg(($pthis-1),(($this->porPagina*($pthis-2))+1),($this->porPagina*($pthis-1)),2),$this->mostrarAnterior);
  36.                 }
  37.                 if(count($this->paginasAntesEspecial) > 0) { // version 2.0
  38.                         $this->paginasAntesEspecial = array_unique($this->paginasAntesEspecial);
  39.                         rsort($this->paginasAntesEspecial);
  40.                         foreach($this->paginasAntesEspecial as $n) {
  41.                                 $page = $before-$n;
  42.                                 if($page < 1 or $page == 1 and $this->mostrarPrimera !== false) continue;
  43.                                 $link_string2[] = $this->do_link($page,$this->addlinkmsg($page,(($this->porPagina*($page-1))+1),($this->porPagina*$page),3),str_replace("{n}", $page, $this->mostrarAdyacentes));
  44.                         }
  45.                 }
  46.                 $i = 0;
  47.                 while($before <= $after) { // Ciclo modificado version 2.0
  48.                         if($this->mostrarAdyacentes !== false and $pthis <> $before) {
  49.                                 $link_string3[] = $this->do_link($before,$this->addlinkmsg($before,(($this->porPagina*($before-1))+1),($this->porPagina*($before)),3),str_replace("{n}", $before, $this->mostrarAdyacentes));
  50.                         } elseif($this->mostrarActual != false and $pthis == $before) {
  51.                                 $link_string3[] = str_replace("{n}", $before, $this->mostrarActual);
  52.                         }
  53.                         $before++;
  54.                 }
  55.                 if(count($this->paginasDespuesEspecial) > 0) { // version 2.0
  56.                         $this->paginasDespuesEspecial = array_unique($this->paginasDespuesEspecial);
  57.                         sort($this->paginasDespuesEspecial);
  58.                         foreach($this->paginasDespuesEspecial as $n) {
  59.                                 $page = $after+$n;
  60.                                 if($page > $ptotal or $page == $ptotal and $this->mostrarUltima !== false) continue;
  61.                                 $link_string4[] = $this->do_link($page,$this->addlinkmsg($page,(($this->porPagina*($page-1))+1),($this->porPagina*$page),3),str_replace("{n}", $page, $this->mostrarAdyacentes));
  62.                         }
  63.                 }
  64.                 if($this->mostrarSiguiente !== false and $pthis < $ptotal) { // Modificado version 2.0
  65.                         $link_string5[] = $this->do_link($pthis+1,$this->addlinkmsg(($pthis+1),(($this->porPagina*$pthis)+1),($this->porPagina*($pthis+1)),4),$this->mostrarSiguiente);
  66.                 }
  67.                 if($this->mostrarUltima !== false and $pthis < ($ptotal-$this->paginasDespues)) { // Modificado version 2.0
  68.                         $link_string5[] = $this->do_link($ptotal,$this->addlinkmsg($ptotal,(($this->porPagina*($ptotal-1))+1),$this->numTotalRegistros,5),$this->mostrarUltima);
  69.                 }
  70.                 $link_string = null;
  71.                 if(!empty($link_string1)) $link_string .= implode($this->linkSeparador,$link_string1).$this->linkSeparador;
  72.                 if(!empty($link_string2)) $link_string .= implode($this->linkSeparadorEspecial,$link_string2).$this->linkSeparadorEspecial;
  73.                 if(!empty($link_string3)) $link_string .= implode($this->linkSeparador,$link_string3);
  74.                 if(!empty($link_string4)) $link_string .= $this->linkSeparadorEspecial.implode($this->linkSeparadorEspecial,$link_string4);
  75.                 if(!empty($link_string5)) $link_string .= $this->linkSeparador.implode($this->linkSeparador,$link_string5);
  76.  
  77.                 return $link_string;
  78.         }

Espero me podais guiar, gracias!!!!!