Author Topic: [Mod] Randomizing {new_images}  (Read 34027 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Mod] Randomizing {new_images}
« 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.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
[Mod] Randomizing {new_images}
« Reply #1 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Muchos gracias !
« Reply #2 on: September 24, 2002, 01:38:49 PM »
Most excellent.  It works for me and you made my day.

Thanks.

Offline releasedj

  • Pre-Newbie
  • Posts: 2
    • View Profile
[Mod] Randomizing {new_images}
« Reply #3 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

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Mod] Randomizing {new_images}
« Reply #4 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.

Offline Clow Read

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • http://vectorcandy.com
[Mod] Randomizing {new_images}
« Reply #5 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 ^_~

Offline Fuztug

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
[Mod] Randomizing {new_images}
« Reply #6 on: March 22, 2003, 09:49:02 PM »
How do I randomize all of my images?!?

Thx,
Fuztud!

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
on a different page?
« Reply #7 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

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
[Mod] Randomizing {new_images}
« Reply #8 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.
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 NeoNuss

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
[Mod] Randomizing {new_images}
« Reply #9 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! :)

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
[Mod] Randomizing {new_images}
« Reply #10 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.
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 NeoNuss

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
[Mod] Randomizing {new_images}
« Reply #11 on: June 18, 2003, 04:06:26 PM »
oops & thx! :D

Offline Amosnet

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • Bilder verkaufen
Re: [Mod] Randomizing {new_images}
« Reply #12 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
I love 4images! http://www.fotos-verkaufen.de Fotos verkaufen online Tips und Tricks und http://www.fotoskaufen.de

Offline supastoked

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • ThoseDudes
Re: [Mod] Randomizing {new_images}
« Reply #13 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

Offline hyde101

  • Sr. Member
  • ****
  • Posts: 410
  • 34TR.COM (Running 4images)
    • View Profile
    • Nostalgia Istanbul
Re: [Mod] Randomizing {new_images}
« Reply #14 on: September 23, 2006, 03:01:00 AM »
Quote
Just replace in index.php


Thank you very much Jan, it works perfect.

Please Vote for my site: Here