Author Topic: Image sort and details navigation  (Read 5855 times)

0 Members and 1 Guest are viewing this topic.

Offline amp

  • Pre-Newbie
  • Posts: 3
    • View Profile
Image sort and details navigation
« on: July 02, 2012, 08:00:03 PM »
Hi, i searched for long time and didn't found a solution.

this is my question:

i have some images, for example image1, image2, image3. each image is in a different category (for example image1 is in category1, image2 in category2, image3 in category3). i created a custom page (called new images) that shows these images from the newest to the oldest, with thumbs and other fields (like category, image author, votes etc etc). It works right. But, when i click the image1, the display.php shows me only image1 and no "next image" button. What i want is show the next image always ordered by date DESC but from another category. For example click image1, next button show me image2, and then image3 regardless of category. Is this possible?

Rembrandt

  • Guest
Re: Image sort and details navigation
« Reply #1 on: July 03, 2012, 04:49:53 AM »
Welcome to the Forum!

..i created a custom page.....
post your custom page...

mfg Andi

Offline amp

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Image sort and details navigation
« Reply #2 on: July 03, 2012, 06:31:41 PM »
Welcome to the Forum!

..i created a custom page.....
post your custom page...

mfg Andi

Hi Rembrandt, thanks for reply!

this is my custom new_image.php page code.
the details.php is the default of 1.7.10 4images version


<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: top.php                                              *
 *        Copyright: (C) 2002-2011 Jan Sorgalla                           *
 *            Email: jan@4homepages.de                                    * 
 *              Web: http://www.4homepages.de                             * 
 *    Scriptversion: 1.7.10                                               *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$main_template 'new_images';

define('GET_CACHES'1);
define('ROOT_PATH''./');
define('MAIN_SCRIPT'__FILE__);
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

$cache_id create_cache_id(
  
'page.top',
  array(
    
$user_info[$user_table_fields['user_id']],
    
$cat_id,
    
$config['template_dir'],
    
$config['language_dir']
  )
);

if (!
$cache_page_top || !$content get_cache_file($cache_id)) {
if (
$cache_page_top) {
  
// Always append session id if cache is enabled
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
}

ob_start();

$cat_match_sql = ($cat_id && check_permission("auth_viewcat"$cat_id)) ? "AND i.cat_id = '$cat_id' " "";
$register_array = array();

$cat_id_sql get_auth_cat_sql("auth_viewcat""NOTIN");
//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':'''$lang['new_images']).")",
  
"rss_url"   => $script_url."/rss.php?action=images"
));

$imgtable_width ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$num_new_images $config['image_cells'];
$config['image_cells'] = 4;
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'];
  
$new_images .= "</td></tr></table>";
}
else  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_images .= "<td class=\"newimagerow\" width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$new_images .= $site_template->parse_template("thumbnail_bit_new_images");
    
$new_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$new_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_images .= "</tr>\n";
    }
  }
  
$new_images .= "</table>\n";
// end else

/*else  {
  $new_images = "<ul class=\"polaroids\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $new_images .= "";
    }
    $new_images .= "<li>";

    show_image($image_row);
    $new_images .= $site_template->parse_template("thumbnail_bit_new_images");
    $new_images .= "</a>";
    $count++;
    if ($count == $config['image_cells']) {
      $new_images .= "</li>";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $new_images .= "</ul>";
      }
      $new_images .= "</li>";
    }
  }
  $new_images .= "</ul>";
}*/

$site_template->register_vars("new_images"$new_images);
unset(
$new_images);


//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"lang_top_image_hits" => $lang['top_image_hits'],
  
"lang_top_image_downloads" => $lang['top_image_downloads'],
  
"lang_top_image_rating" => $lang['top_image_rating'],
  
"lang_top_image_votes" => $lang['top_image_votes']
));
$site_template->print_template($site_template->parse_template($main_template));

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_top) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

// end if get_cache_file()

echo $content;

include(
ROOT_PATH.'includes/page_footer.php');
?>

Rembrandt

  • Guest
Re: Image sort and details navigation
« Reply #3 on: July 03, 2012, 08:00:48 PM »
ok... search in details.php:

if ($mode == "lightbox") {

insert above:

if($mode == "new_images"){
 
  
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
          FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
          LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
          WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
          ORDER BY i.image_date DESC"
;

  
$in_mode 1;
}


search:

if ($mode == "lightbox" && $in_mode) {

insert above:

if ($mode == "new_images" && $in_mode) {
  
$page_url "";
 if (
preg_match("/".URL_PAGE."=([0-9]+)/"$url$regs)) {
    if (!empty(
$regs[1]) && $regs[1] != 1) {
      
$page_url "?".URL_PAGE."=".$regs[1];
    }
  }
  
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."new_image.php".$page_url)."\" class=\"clickstream\">".$lang['new_images']."</a>".$config['category_separator'];
}


Search in your "custom new_image.php":

show_image
($image_row);

and replace:

show_image
($image_row,"new_images");


mfg Andi
« Last Edit: July 03, 2012, 08:21:09 PM by Rembrandt »

Offline amp

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Image sort and details navigation
« Reply #4 on: July 03, 2012, 08:14:30 PM »
MAN, you're GREAT!

you saved my life :mrgreen:

thank you very much!