Pozdrav,
Treba pomoc oko paginacije, želim da sklonim 0 sa prve stranice. Npr.
Imam link koji izgleda ovako
srbija/beograd
tu mi se izlistaju svi smeštaji u beogradu (10 smeštaja po stranici), kada idem na link next link izgleda ovako
srbija/beograd/1
tu nastaje za mene problem jer mi previous link izgleda ovako
srbija/beograd/0
želim da izbegnem "0" mislim da je rešenje if statement ali nemogu nikako da ga ubacim
želim da ubacim nešto ovako
if $pageNum_Recordset1 -1 == 0
"<a href=\"/en$_get_vars\">$prev_Recordset1</a>"
evo i koda koji koristim
function buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator=" | ",$max_links=5, $show_page=true)
{
GLOBAL $maxRows_Recordset1,$totalRows_Recordset1;
$pagesArray = ""; $firstArray = ""; $lastArray = "";
if($max_links<2)$max_links=2;
if($pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0)
{
if ($pageNum_Recordset1 > ceil($max_links/2))
{
$fgp = $pageNum_Recordset1 - ceil($max_links/2) > 0 ? $pageNum_Recordset1 - ceil($max_links/2) : 1;
$egp = $pageNum_Recordset1 + ceil($max_links/2);
if ($egp >= $totalPages_Recordset1)
{
$egp = $totalPages_Recordset1+1;
$fgp = $totalPages_Recordset1 - ($max_links-1) > 0 ? $totalPages_Recordset1 - ($max_links-1) : 1;
}
}
else {
$fgp = "0";
$egp = $totalPages_Recordset1 >= $max_links ? $max_links : $totalPages_Recordset1+1;
}
if($totalPages_Recordset1 >= 1) {
# ------------------------
# Searching for $_GET vars
# ------------------------
$_get_vars = '';
if(!empty($_GET) || !empty($HTTP_GET_VARS)){
$_GET = empty($_GET) ? $HTTP_GET_VARS : $_GET;
foreach ($_GET as $_get_name => $_get_value) {
if ($_get_name != "pageNum_Recordset1") {
$_get_vars .= "/$_get_value";
}
}
}
$successivo = $pageNum_Recordset1+1;
$precedente = $pageNum_Recordset1-1;
$firstArray = ($pageNum_Recordset1 > 0) ?
"<a href=\"/en$_get_vars/$precedente\">$prev_Recordset1</a>" : "$prev_Recordset1";
# ----------------------
# page numbers
# ----------------------
for($a = $fgp+1; $a <= $egp; $a++){
$theNext = $a-1;
if($show_page)
{
$textLink = $a;
} else {
$min_l = (($a-1)*$maxRows_Recordset1) + 1;
$max_l = ($a*$maxRows_Recordset1 >= $totalRows_Recordset1) ? $totalRows_Recordset1 : ($a*$maxRows_Recordset1);
$textLink = "$min_l - $max_l";
}
$_ss_k = floor($theNext/26);
if ($theNext != $pageNum_Recordset1)
{
$pagesArray .= "<a href=\"/en$_get_vars/$theNext\">";
$pagesArray .= "$textLink</a>" . ($theNext < $egp-1 ? $separator : "");
} else {
$pagesArray .= "$textLink" . ($theNext < $egp-1 ? $separator : "");
}
}
$theNext = $pageNum_Recordset1+1;
$offset_end = $totalPages_Recordset1;
$lastArray = ($pageNum_Recordset1 < $totalPages_Recordset1) ? "<a href=\"/en$_get_vars/$successivo\">$next_Recordset1</a>" : "$next_Recordset1";
}
}
return array($firstArray,$pagesArray,$lastArray);
}
|