4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Chris on September 24, 2002, 03:00:55 AM

Title: [Mod] Randomizing {new_images}
Post by: Chris on September 24, 2002, 03:00:55 AM
I use 4images for my personal photography.  When I add new images, I always do it in bulk.  That is, I typically use FTP to upload 10 to 100 images and then use the admin control panel 'Check New Images' to add all of them at once.

{new_images} used in the home.html template always displays the LAST <Image table cells> number of new images.  (which for me is 4)  

How can I randomize which 4 new images are displayed in place of the {new_images} template tag?  

By that I mean I want to randomly display 4 new images rather than the LAST 4 new images added.
Title: [Mod] Randomizing {new_images}
Post by: Jan on September 24, 2002, 08:38:04 AM
Just replace in index.php
Code: [Select]
ORDER BY i.image_date DESC
with
Code: [Select]
AND i.image_date >= ".(time() - 60 * 60 * 24 * $config['new_cutoff'])."
ORDER BY RAND()

This requires MySQL version >= 3.23.23

Greets Jan
Title: Muchos gracias !
Post by: Chris on September 24, 2002, 01:38:49 PM
Most excellent.  It works for me and you made my day.

Thanks.
Title: [Mod] Randomizing {new_images}
Post by: releasedj on February 07, 2003, 04:53:26 PM
I don't think this will work if you don't have any new images.

I posted another post to show something a little more intelligent.

http://www.4homepages.de/forum/viewtopic.php?t=4010
Title: [Mod] Randomizing {new_images}
Post by: Chris on February 07, 2003, 06:21:21 PM
Thanks.  I'll check it out, although I think I'm happy with not showing any new images if they are outside the cutoff date.
Title: [Mod] Randomizing {new_images}
Post by: Clow Read on February 10, 2003, 05:48:13 AM
could you create a mod that will have a feature where the randomized new images could be placed outside 4images??? ^^

thnx ^_~
Title: [Mod] Randomizing {new_images}
Post by: Fuztug on March 22, 2003, 09:49:02 PM
How do I randomize all of my images?!?

Thx,
Fuztud!
Title: on a different page?
Post by: bernd on June 07, 2003, 01:06:46 PM
Hi,

I want to display new images not on the homepage but on a "static" page (a page that is called with "... index.php?template=news" for instance) and I add {new_images} there it's empty. If I have it in the home.html it works so there are new images that fall into this category.

Any idea what I need to change where to get it to work?

Thanks in advance,
Bernd
Title: [Mod] Randomizing {new_images}
Post by: V@no on June 07, 2003, 05:17:32 PM
because custom template prcessed before everything else generated.
maby try comment this in index.php:
Code: [Select]
if (!empty($template)) {
  $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_", " ", ucfirst($template));
  $site_template->register_vars("clickstream", $clickstream);
  $site_template->print_template($site_template->parse_template($main_template));
  include(ROOT_PATH.'includes/page_footer.php');
}

but this way clickstream will be messed up.
Title: [Mod] Randomizing {new_images}
Post by: NeoNuss on June 13, 2003, 07:53:09 PM
I have mysql-version 3.23.14 and i get the following error on my index.php:

Code: [Select]
DB Error: Bad SQL Query: 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, c.cat_name, u.name FROM cb_gallery_images i, cb_gallery_categories c LEFT JOIN cb_ivb_members u ON (u.id = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (0, 12, 13, 14, 3, 10, 4, 15, 1, 5, 11, 7, 9, 8) // ORDER BY i.image_date DESC AND i.image_date >= 1054663003 ORDER BY RAND() ORDER BY RAND() LIMIT 3
You have an error in your SQL syntax near '/ ORDER BY i.image_date DESC AND i.image_date >= 1054663003 ORDER BY RA' at line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/www/htdocs/ivb/gallery/includes/db_mysql.php on line 116


help! :)
Title: [Mod] Randomizing {new_images}
Post by: V@no on June 13, 2003, 09:59:38 PM
SQL query is just a string, because of that u CAN NOT comment like this:
Quote
// ORDER BY i.image_date DESC AND i.image_date >= 1054663003
ORDER BY RAND() ORDER BY RAND() LIMIT 3

also, u got too many ORDER BY things, remove them, leave just one.
Title: [Mod] Randomizing {new_images}
Post by: NeoNuss on June 18, 2003, 04:06:26 PM
oops & thx! :D
Title: Re: [Mod] Randomizing {new_images}
Post by: Amosnet on March 17, 2005, 10:30:03 PM
I have used the old randomized NEW IMAGES MOD, but now i lost my index.php and have to create
it new.

Can please somebody tell me how it works to show the last 6 random new images?

Thanks
Title: Re: [Mod] Randomizing {new_images}
Post by: supastoked on July 15, 2005, 08:55:24 PM
Hey Guys,
Is it possible to "randomize" through a specific category?? If we upload a new cat with a number of images every couple of days, it would be kewl to randomize through the "new" latest cat?? I have tried changing the "new" period to a more recent one, but it still shows up old pics from 2 months ago, because they were only uploaded in the past 7 days.. Any suggestions??
TIA
Chris
Title: Re: [Mod] Randomizing {new_images}
Post by: hyde101 on September 23, 2006, 03:01:00 AM
Quote
Just replace in index.php


Thank you very much Jan, it works perfect.
Title: Re: [Mod] Randomizing {new_images}
Post by: tripiyon on May 03, 2008, 08:06:57 PM
Hi,

I have Mysql 5.0.45 and me the script does not work.
What change do I need in the code in order that it works well?

Thanks


Just replace in index.php
Code: [Select]
ORDER BY i.image_date DESC with
Code: [Select]
AND i.image_date >= ".(time() - 60 * 60 * 24 * $config['new_cutoff'])."
ORDER BY RAND()
This requires MySQL version >= 3.23.23

Greets Jan
Title: Re: [Mod] Randomizing {new_images}
Post by: tripiyon on May 03, 2008, 09:18:45 PM
Solved  :D

Thanks

http://www.4homepages.de/forum/index.php?topic=7430.0
Title: Re: [Mod] Randomizing {new_images}
Post by: relu on March 15, 2012, 04:32:45 PM
I'm using it but i notticed that page is loading after a few secconds... 15-20 sec of thinking. Without the randomizing code is instant.