4 de ago. de 2012

Páginas Avançadas

Este tutorial foi tirado dofórum oficial do Cutenews, e traduzido porMadly Luv.

Hoje vim trazer um tutorial do Cutenews. Quem usa o Cutenews e tem muitas páginas, vê que fica feio com aquele monte de números em baixo do post, neste tutorial vamos aprender a fazer mostrar sua lista de nº de post que era assim:

<< Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next >>

Para ficar assim:

<< Previous 1 2 3 4 5... 10 11 12 Next >>

1º Vá na pasta inc e faça o download (por FTP de preferência) do arquivo shows.inc.php.

Abra-o no bloco de notas e procure a seguinte parte:


//———————————-
// Pages
//———————————-
if($number){
$pages_count = @ceil($count_all/$number);
$pages_start_from = 0;
$pages = "";
for($j=1;$j<=$pages_count;$j++){
if($pages_start_from != $start_from){ $pages .= "<a href="$PHP_SELF?start_from=$pages_start_from&ucat=$ucat
&archive=$url_archive&subaction=$subaction&id=$id&$user_query">$j</a> "; }
else{ $pages .= " <strong>$j</strong> "; }
$pages_start_from += $number;
}
$prev_next_msg = str_replace("{pages}", $pages, $prev_next_msg);
}
Agora substitua pelo seguinte código:

//----------------------------------
// Pages
//----------------------------------
if ($number){
$total_pages = @ceil($count_all / $number);
$current_page = ($start_from/$number) + 1;
$pages = '';
//Advanced pagination
if ($total_pages > 10){
//Left block
$pages_start = 1;
$pages_max = $current_page >= 5 ? 3 : 5;
for($j = $pages_start; $j <= $pages_max; $j++){
if($j == $current_page){
$pages .= '<b>'.$j.' </b>';
}
else{
$pages .= '<a href="'.$PHP_SELF.'?start_from='.(($j - 1) * $number).'&ucat='.$ucat.
'&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' </a>';
}
}
$pages .= '... ';
//Middle block
if($current_page > 4 && $current_page < ($total_pages - 3)){
$pages_start = $current_page - 1;
$pages_max = $current_page + 1;
for($j = $pages_start; $j <= $pages_max; $j++){
if($j == $current_page){
$pages .= '<b>'.$j.' </b>';
}
else{
$pages .= '<a href="'.$PHP_SELF.'?start_from='.(($j - 1) * $number).'&ucat='.$ucat.
'&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' </a>';
}
}
$pages .= '... ';
}
//Right block
$pages_start = $current_page <= $total_pages - 4 ? $total_pages - 2 : $total_pages - 4;
$pages_max = $total_pages;
for($j = $pages_start; $j <= $pages_max; $j++){
if($j == $current_page){
$pages .= '<b>'.$j.' </b>';
}
else{
$pages .= '<a href="'.$PHP_SELF.'?start_from='.(($j - 1) * $number).'&ucat='.$ucat.
'&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' </a>';
}
}
}
//Normal pagination
else {
for ($j = 1; $j <= $total_pages; $j++){
if ((($j - 1) * $number) != $start_from){
$pages .= '<a href="'.$PHP_SELF.'?start_from='.(($j - 1) * $number).'&ucat='.$ucat.
'&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' </a> ';
} else {
$pages .= ' <b>'.$j.'</b> ';
}
}
}
$prev_next_msg = str_replace('{pages}', $pages, $prev_next_msg);
Agora é só salvar e sobrepor o arquivo. Ate o próximo tuto.