Foros del Web » Programando para Internet » PHP »

Paginación me da error

Estas en el tema de Paginación me da error en el foro de PHP en Foros del Web. Buenas tardes. Estoy con el código de una paginación para un blog. He econtrado una clase que con pocas lineas de código, sacas la paginación. ...
  #1 (permalink)  
Antiguo 09/01/2017, 09:02
 
Fecha de Ingreso: marzo-2015
Ubicación: Valencia
Mensajes: 132
Antigüedad: 9 años, 1 mes
Puntos: 0
Paginación me da error

Buenas tardes.

Estoy con el código de una paginación para un blog. He econtrado una clase que con pocas lineas de código, sacas la paginación.

El problema es que al ponerle el "style" para que no salgan los numeros basicos, me encuentro que si me aplica bien el estilo, menos en la página actual.
Es decir si me encuentro en la página 1, me sale esto...

2 Siguiente 1 (el 2 y el siguiente si tienen estilos, pero el 1 no)

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

Luego creo que esto es lo que manda sobre ello, es la primera vez que hago una paginación y todo este código me queda grande.


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 "<a href=\"$href\"$title$estilo>$content</a>";
  7.         }

Espero me podais arrojar un poco de luz... Gracias
  #2 (permalink)  
Antiguo 09/01/2017, 10:55
 
Fecha de Ingreso: octubre-2009
Mensajes: 305
Antigüedad: 14 años, 6 meses
Puntos: 29
Respuesta: Paginación me da error

no entendí Nada
  #3 (permalink)  
Antiguo 11/01/2017, 08:57
 
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!!!!!
  #4 (permalink)  
Antiguo 11/01/2017, 13:40
 
Fecha de Ingreso: diciembre-2015
Ubicación: rosario
Mensajes: 69
Antigüedad: 8 años, 4 meses
Puntos: 5
Respuesta: Paginación me da error

podes poner un printscreen de lo q contas, es decir, del nro que te queda fuera del estilo, xq me parece que ya se q es y no es php, si no css
  #5 (permalink)  
Antiguo 12/01/2017, 04:35
 
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

Cita:
Iniciado por infoturnosya Ver Mensaje
podes poner un printscreen de lo q contas, es decir, del nro que te queda fuera del estilo, xq me parece que ya se q es y no es php, si no css
Me puedes decir como hacer ese printscreen???

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:29.