Hi!
Here was asked for a paging for the detail page ala "fotocommunity.
http://www.4homepages.de/forum/index.php?topic=28375.msg153266#msg153266This Modification is good for many images in one Category.
Codeupdate: step 2.) 23.06.2011Demo1.) search in lang/your lang/main.php:
//-----------------------------------------------------
//--- Paging ------------------------------------------
//-----------------------------------------------------
insert below(english):
$lang['paging_lastimage'] = "Last Image";
$lang['paging_firstimage'] = "First Image";
insert below(deutsch):
$lang['paging_lastimage'] = "Letztes Bild";
$lang['paging_firstimage'] = "Erstes Bild";
2.) search in details.php:
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
insert above:
//##################################### Start MOD: Detail Paging ###################################
$sql = "SELECT image_id, cat_id, image_name
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id = $cat_id
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
";
$result = $site_db->query($sql);
while($row = $site_db->fetch_array($result)){
$image_preview[] = $row['image_id'];
$preview_row[$row['image_id']] = $row;
}
function detailpaging($start,$step,$current,$stop,$offset,$min=0){
global $site_sess,$script_url,$image_preview,$preview_row;
for ($t = $start; $t <= ($stop);){
if(($min == 1) ? ($t < $offset && ($t < $current)) : ($t > $current && ($t < $offset))){
$paging = "<td class=\"detailpaging2\"><a href=".$site_sess->url($script_url."/details.php?".URL_IMAGE_ID."=".$preview_row[$image_preview[$t-1]]['image_id'])." title=\"".$preview_row[$image_preview[$t-1]]['image_name']."\">$t</a></td>\n";
}
$t+=$step;
}
$td = (isset($paging))? "<td>...</td>\n":"\n";
$td = ($min==1) ? ((isset($paging)) ? $paging: "").$td : $td.((isset($paging)) ? $paging: "");
return $td;
}
$num_rows_all = (isset($cat_cache[$cat_id]['num_images'])) ? $cat_cache[$cat_id]['num_images'] : 0;
$offset = $num_rows_all-1;
$total = 7 ;
$lastPage = count($image_preview);
$table_start = "<table><tr>\n";
if($lastPage < ($total + 1)){
$start = 0;
$end = $lastPage -1;
}
elseif ($act_key <= (($total-1)/2 -1)){
$start = 0;
$end = ($total - 1);
}
elseif ($act_key >= $lastPage - (($total-1)/2)){
$start = $lastPage - $total;
$end = $lastPage - 1;
}
else {
$start = $act_key - ($total-1)/2;
$end = $act_key + ($total-1)/2;
}
$list="";
$current="";
for($i=$start; $i<=$end; $i++){
$d=$i+1;
if ($preview_row[$image_preview[$i]]['image_id'] == $image_row['image_id']) {
$list .= "<td class=\"detailpaging1\">\n";
$current= $d;
}
else {
$list .= "<td class=\"detailpaging2\">\n";
}
$list .= "<a href=".$site_sess->url($script_url."/details.php?".URL_IMAGE_ID."=".$preview_row[$image_preview[$i]]['image_id'])." title=\"".$preview_row[$image_preview[$i]]['image_name']."\">".$d."</a>";
$list .= "</td>\n";
}
$table_end = "</tr></table><br>\n";
//-----------------------------------------------------------
$first_image="";
if (($current*2-1) > $total) {
$first_image ="<td class=\"detailpaging2\"><a href=".$site_sess->url($script_url."/details.php?".URL_IMAGE_ID."=".$preview_row[$image_preview[0]]['image_id'])." title=\"".$preview_row[$image_preview[$offset]]['image_name']."\">".$lang['paging_firstimage']."</td>\n";
$first_image .="<td>...</td>\n";
}
$last_image="";
if ((($current-2) + (round($total/2))) < $offset) {
$last_image ="<td>...</td>\n";
$last_image .="<td class=\"detailpaging2\"><a href=".$site_sess->url($script_url."/details.php?".URL_IMAGE_ID."=".$preview_row[$image_preview[$offset]]['image_id'])." title=\"".$preview_row[$image_preview[$offset]]['image_name']."\">".$lang['paging_lastimage']."</td>\n";
}
//-----------------------------------------------------------
$pageminus_10 = detailpaging(10,10,$current-ceil(round($total/2)),50,(ceil($current/10)*10)+ceil(round($total/2)),1);
$pageminus_100 = detailpaging(100,100,$current-ceil(round($total/2)),500,((ceil(($current-$total)/100)*100)+ceil(round($total/2))),1);
$pageminus_1000 = detailpaging(1000,1000,$current-ceil(round($total/2)),5000,((ceil(($current-$total)/1000)*1000)+ceil(round($total/2))),1);
$pageplus_10 = detailpaging(10,10,$current+floor(round($total/2)),((ceil($current))+50+floor(round($total/2))),$offset);
$pageplus_100 = detailpaging(100,100,($current+50+floor(round($total/2))),((ceil($current))+550+floor(round($total/2))),$offset);
$pageplus_1000 = detailpaging(1000,1000,($current+550+floor(round($total/2))),((ceil($current))+5500+floor(round($total/2))),$offset);
$detail_paging = $table_start.$first_image.$pageminus_10.$pageminus_100.$pageminus_1000.$list.$pageplus_10.$pageplus_100.$pageplus_1000.$last_image.$table_end;
$site_template->register_vars("detail_paging", $detail_paging);
//##################################### End MOD: Detail Paging ###################################
3.) search in your templates/style.css
.tablehead {insert above:
.detailpaging1 {
margin:0px;
padding:0px;
background-color : #FFFFFF;
text-align : center;
vertical-align : middle;
border : 1px solid red;
}
.detailpaging2 {
margin:0px;
padding:0px;
background-color : #FFFFFF;
text-align : center;
vertical-align : middle;
border : 1px solid #CCCCCC;
}
.detailpaging2 :hover{
background-color : red;
}
4.) search in your templates/detail.html:
<hr size="1" />
insert below:
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center">{detail_paging}</td>
</tr>
</table>
that's all..
mfg Andi