Author Topic: [Mod] Paging for Detail site  (Read 10742 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] Paging for Detail site
« on: December 02, 2010, 07:06:05 PM »
Hi!
 
Here was asked for a paging for the detail page ala "fotocommunity.
http://www.4homepages.de/forum/index.php?topic=28375.msg153266#msg153266

This Modification is good for many images in one Category.

Codeupdate: step 2.) 23.06.2011

Demo

1.) 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 
    
$lastPage count($image_preview);
    
$table_start "<table><tr>\n";
       
    if(
$lastPage < ($total 1)){
      
$start 0;
      
$end $lastPage -1;
    }
    elseif (
$act_key <= (($total-1)/-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:
Code: [Select]
<hr size="1" />insert below:
Code: [Select]
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td align="center">{detail_paging}</td>
  </tr>
</table>

that's all..

mfg Andi
« Last Edit: August 22, 2012, 08:16:00 AM by Rembrandt »

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: [Mod] Paging for Detail site
« Reply #1 on: December 02, 2010, 09:18:11 PM »
Danke, vor allem für den wenigen Code  :wink:

Edit:
Andi, nehme mal aus Step2 das "<?php" raus  :wink:
Danke Harald




Offline juewei

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: [Mod] Paging for Detail site
« Reply #2 on: December 02, 2010, 10:03:33 PM »
hallo Andi!

Danke für deine super perfekte Arbeit! Schaut richtig gut aus, für mich ist heute schon Weihnachten und du bist der Weihnachtsmann :D

Und dann noch so, dass es bei mir auch auf Anhieb geklappt hat. Danke :!:

Jue

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Re: [Mod] Paging for Detail site
« Reply #3 on: December 02, 2010, 10:51:15 PM »
Hi,

das war also der geplante 2000. Post ;)


Gruß Jens

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--

Offline urmasmuld

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: [Mod] Paging for Detail site
« Reply #4 on: August 16, 2011, 10:22:02 AM »
How can i modify this mod so i can just show number of images in this category and which picture is showed ?
Now it shows :  1 2 3 ... 50 .. 100
But I just want to show this : 5/100