4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: qazew on March 02, 2010, 08:26:50 PM
-
Sorry for my english, but I am need some modification in the details.php
the metter is that, when in the category I watch the last picture, the next thumb image is empty. how I can do that to me show the next thumb image of next image ID?
For example, I watch last picture in the "Main" category with id=8. In the standart details.php the next image will be empty. But i am need in this case to show thumb of image with id=9 (if such photo is exist).
And show previous image from other cat if in this cat it is first photo
Thank you!
-
Welcome to 4images forum.
Try this. In details.php find:
unset($image_id_cache);
Insert above:
if (!$in_mode && !$next_image_id)
{
$sq1 = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id > $image_id
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
LIMIT 1";
if ($row = $site_db->query_firstrow($sq1))
{
$next_image_id = $row['image_id'];
$next_prev_cache[$next_image_id] = $row;
}
$site_db->free_result();
}
It might show image from the same category, if you don't want that, then replace
WHERE image_active = 1 AND image_id > $image_id
With:
WHERE image_active = 1 AND image_id > $image_id AND cat_id <> $cat_id
-
Thank you! It work but I am desided to make some changes because your code circeled in the higher subcat. At me work not correct, so I decided to change and select next ID picture. Aslo add previous image if it first in the cat. here the code
//-----NEXT IMAGE FROM OTHER CAT -------------
if (!$in_mode && !$next_image_id)
{
$sq1 = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id = $image_id+1
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
LIMIT 1";
if ($row = $site_db->query_firstrow($sq1))
{
$next_image_id = $row['image_id'];
$next_prev_cache[$next_image_id] = $row;
}
$site_db->free_result();
}
if (!$in_mode && !$prev_image_id)
{
$sq2 = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id = $image_id-1
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
LIMIT 1";
if ($row = $site_db->query_firstrow($sq2))
{
$prev_image_id = $row['image_id'];
$next_prev_cache[$prev_image_id] = $row;
}
$site_db->free_result();
}
//---------END--------------------------------
At me it is work good. When in the cat I watch last image the next image will be ID of current picture+1. I am hope I am made all correct. Can you check the code lines, may be can to correct code the the lines will be less. I am not sure why need to have two similar lines $next_prev_cache[$prev_image_id] = $row;
-
now, try this situation. there are 4 images in one category with ids: 1,2,3,4
in second category there are 3 images with ids: 5,6,7
when you open image 4, it will show next image 5 from another category - good. now delete image 5 and 3. open image 4, it wont show any next images...
-
ok, I am modified the code and finaly get such code:
//-----NEXT IMAGE FROM OTHER CAT -------------
if (!$in_mode && !$next_image_id)
{
$sq1 = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id > $cat_id
ORDER BY cat_id, ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
LIMIT 1";
if ($row = $site_db->query_firstrow($sq1))
{
$next_image_id = $row['image_id'];
$next_prev_cache[$next_image_id] = $row;
}
$site_db->free_result();
}
if (!$in_mode && !$prev_image_id)
{
if(substr($config['image_sort'],0,1)=="D") $image_prev_sort="ASC"; else $image_prev_sort="DESC";
$sq2 = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id < $cat_id
ORDER BY cat_id DESC, ".$config['image_order']." ".$image_prev_sort.", image_id ".$image_prev_sort."
LIMIT 1";
if ($row = $site_db->query_firstrow($sq2))
{
$prev_image_id = $row['image_id'];
$next_prev_cache[$prev_image_id] = $row;
}
$site_db->free_result();
}
//---------END--------------------------------
in the "Image settings" I have Sort images by Date.
When you reach the last image in the category in next preview, you get next thumbnail image from next category.
Please check. need to work
-
These codes are great but i want something different: Your code makes next image of the next category but i want first image of the same category. Could you modify that?
-
Replace
WHERE image_active = 1 AND image_id > $image_id
with:
WHERE image_active = 1 AND cat_id = $cat_id
-
But i cant find this query because i used the qazew's code not yours. So can you look at this?
-
Then search for
WHERE image_active = 1 AND cat_id > $cat_id
-
- When i get the last picture it jumps in the same category to the second pic and not the first.
- What i have to add to jump from the first to the last ( << backward) ?
-
Next button is ok, working very well, but prev. button, if its the first image of the cat. its loading previous category, how can i make load the last image of the same category like next button do.
-
You got to specify which code you are using.
-
i am using qazew's code with your modification.
-
i am using qazew's code with your modification.
Try to use a Vano's code in the second message. If I am correctly understood you what you want, this code will fine for you