Author Topic: Category Thumnails & Detail Image on the same page?  (Read 4820 times)

0 Members and 1 Guest are viewing this topic.

Offline netx_dev

  • Pre-Newbie
  • Posts: 7
    • View Profile
Category Thumnails & Detail Image on the same page?
« on: February 05, 2009, 03:42:40 PM »
Hi there...Your gallery is cool but...

in english:

When I try to get the category thumnails & detail image on the same page there happes to be an error. The last category thumbnail is also used as the detail image displayed. Much more I would like to have the first thumbnail displayed as detail image. I used the {image} tag to include the detail image in "details.html" and {thumbnail} for the thumnails. But since there is an image variable, that seems to keep overwritten in a loop by the newest image id, this wont work. Is there any solution to this?  :roll:

auf deutsch:

Würde gerne das Detail Bild zusammen mit den Thumnails auf einer Seite anzeigen lassen. Grundsätzlich geht das auch, nur ist das Detail Bild leider nicht das erste Thumbnail sondern das letzte. In der Datei "details.html" binde ich das Detail image mit {image} ein und weiter unten die Thumbnails mit {thumbnails}. Da jedoch die image Variable in einer Schlaufe immer wieder überschrieben wird entspricht natürlich {image} der image ID des letzten thumnails. Gibts hier eine Lösung?  :roll:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Category Thumnails & Detail Image on the same page?
« Reply #1 on: February 05, 2009, 03:54:46 PM »
Welcome to 4images forum.

Perhaps this can help:
http://www.4homepages.de/forum/index.php?topic=24058.msg131871#msg131871
After the change you can use {thumb} tag in details.html template.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline netx_dev

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Category Thumnails & Detail Image on the same page?
« Reply #2 on: February 05, 2009, 08:36:56 PM »
Thanks for the answer but it doesnt help. My idea was simply to add the categories (shown as thumbnails) below the big detail image. So I added
Quote
$templates_used = 'categories,category_bit,thumbnail_bit';
from categories.php to details.php as well as
Quote
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "has_rss"   => true,
  "rss_title" => "RSS Feed: ".format_text($cat_cache[$cat_id]['cat_name'], 2)." (".str_replace(':', '', $lang['new_images']).")",
  "rss_url"   => $script_url."/rss.php?action=images&".URL_CAT_ID."=".$cat_id
));

$num_rows_all = (isset($cat_cache[$cat_id]['num_images'])) ? $cat_cache[$cat_id]['num_images'] : 0;
$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();

$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));

$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;
  }
}

$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 i.cat_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
        LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

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

    show_image($image_row);
    $thumbnails .= $site_template->parse_template("thumbnail_bit");
    $thumbnails .= "\n</td>\n";

    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover > 0) {
      for ($i = 0; $i < $leftover; $i++){
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);

The categories are listed below the detail image, but the detail image equals the last image of the categories instead of the image one clicks to view.

Offline netx_dev

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Category Thumnails & Detail Image on the same page?
« Reply #3 on: February 05, 2009, 10:24:38 PM »
Ok, I figured it out - problem solved....

Your post did help me. It was not the solution you gave me but it helped me to find my own solution. Instead of the thumbnail code I inserted this:

Code: [Select]
$site_template->register_vars("image_main", get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, 0, 0));

...and some more code 8)

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: Category Thumnails & Detail Image on the same page?
« Reply #4 on: February 05, 2009, 10:59:10 PM »
you could put your code below page_header.php include
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.

Offline thorstenp

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Category Thumnails & Detail Image on the same page?
« Reply #5 on: February 06, 2009, 10:48:11 PM »
Ok, I figured it out - problem solved....

Your post did help me. It was not the solution you gave me but it helped me to find my own solution. Instead of the thumbnail code I inserted this:

Code: [Select]
$site_template->register_vars("image_main", get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, 0, 0));

...and some more code 8)

Kannst Du mir mal per PN die URL schicken wo man sich das ansehen kannwas du gebastelt hast ?

Gruss
Thorsten