Author Topic: [Mod] Display random images on homepage, if no new images  (Read 68126 times)

0 Members and 1 Guest are viewing this topic.

Offline police22

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • The Dartez Page
Re: [Mod] Display random images on homepage, if no new images
« Reply #15 on: April 25, 2005, 08:07:23 PM »
..SNIP
At line 81 in index.php (with version 1.7), you will see the following code:
..SNIP
this should do it for you.
Regards,
Kelvin
So V@no, will this work with 1.7.1
gonna go ahead and try real quick but thought i should ask

Offline police22

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • The Dartez Page
Re: [Mod] Display random images on homepage, if no new images
« Reply #16 on: April 25, 2005, 08:13:45 PM »
..SNIP
At line 81 in index.php (with version 1.7), you will see the following code:
..SNIP
this should do it for you.
Regards,
Kelvin
So V@no, will this work with 1.7.1
gonna go ahead and try real quick but thought i should ask
Well.. i installed it.. have new images on there so cant test but it didn't error... Thanks

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: [Mod] Display random images on homepage, if no new images
« Reply #17 on: April 26, 2005, 12:28:30 AM »
u can lower your "new images" timeout in the settings ;)
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 garett

  • Pre-Newbie
  • Posts: 9
    • View Profile
    • Dragon Family
Re: [Mod] Display random images on homepage, if no new images
« Reply #18 on: July 10, 2005, 10:25:03 PM »
that answer made me look into the code... :lol:
replace:
Code: [Select]
       ORDER BY random_no DESC, i.image_date DESCwith:
Code: [Select]
       ORDER BY random_no DESC, RAND(), i.image_date DESC

Do you know if there is a mod that do the same thing but with the categories (and sub-categories) and not with the homepage?
I mean if there is no image in a categorie, you display a line of random images from the subcategories.

It would makes the site more dynamic.


Offline egyptsons

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Egypt Sons
Re: [Mod] Display random images on homepage, if no new images
« Reply #19 on: December 11, 2005, 12:32:45 PM »
nice work I will try it  8)
Thanx God

Offline obmob01

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Display random images on homepage, if no new images
« Reply #20 on: March 16, 2006, 02:24:52 AM »
Oh, i added this to 1.7.2, seems to work fine.

Code: [Select]
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$num_new_images = $config['image_cells'];
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, 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 random_no DESC, RAND(), i.image_date DESC
        LIMIT $num_new_images";

Offline viper357

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [Mod] Display random images on homepage, if no new images
« Reply #21 on: March 25, 2006, 12:31:53 PM »
hey thanks man, I also added it to 1.7.2 and it works great  :D

Offline Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Mod] Display random images on homepage, if no new images
« Reply #22 on: May 03, 2006, 05:02:39 PM »
Quote from: V@no
hum...no
that answer made me look into the code... :lol:
replace:
Code: [Select]
        ORDER BY random_no DESC, i.image_date DESCwith:
Code: [Select]
        ORDER BY random_no DESC, RAND(), i.image_date DESC
Does this mean, ONLY if there are no NEW images, it will take some other random?
(Das heisst also, erst wenn es keine "neuen" Bilder mehr hat, wird aus allen ausgewählt?)
Regards
Sopur

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: [Mod] Display random images on homepage, if no new images
« Reply #23 on: May 04, 2006, 12:13:58 AM »
Yes, if there are some new images they will be displayed in random order, but it there no new images, then it will show random images from entire gallery.
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 Ch*yeuk

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: [Mod] Display random images on homepage, if no new images
« Reply #24 on: July 18, 2006, 11:08:05 PM »
Hahah, awesome! Done it, and love it

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [Mod] Display random images on homepage, if no new images
« Reply #25 on: September 03, 2006, 08:35:51 PM »
This little hack allows you to see random new images on the home page that fall within the cuttof limit, this makes the page look more active.
Code: [Select]
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$num_new_images = $config['image_cells'];
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, 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 IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY random_no DESC, i.image_date DESC
        LIMIT $num_new_images";

Is this possible to Exclude one category from this block of code ??
I dont want to show new/random images from One category
I m not a  Programmer.
          But
I m a Good Learner.

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: [Mod] Display random images on homepage, if no new images
« Reply #26 on: September 03, 2006, 08:48:08 PM »
Add code in red in this line:[qcode]       WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id NOT IN(1,2,3,4,5)
[/qcode]
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 Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [Mod] Display random images on homepage, if no new images
« Reply #27 on: September 03, 2006, 09:09:35 PM »
Thankx V@no
You are The Guru  :D
I m not a  Programmer.
          But
I m a Good Learner.

Offline eXtremer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Randomize old images if there is no NEW for version 1.7.6 [MOD]
« Reply #28 on: September 20, 2008, 01:02:17 PM »
Hi all.
I've searched the forum and found only this : http://www.4homepages.de/forum/index.php?topic=4010.0
..but I can't integrate it in 1.7.6 version there is no such lines in index.php
Could someone give me another MOD ?
Help please.

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: Randomize old images if there is no NEW for version 1.7.6 [MOD]
« Reply #29 on: September 20, 2008, 04:10:08 PM »
The code changed a little, some brackets were added on the second line..
it is around line 106...
in version 1.7.6, it looks like this now
Code: [Select]
$num_new_images = $config['image_cells'];
$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";
replace this with what is in that mod and it should work for you...
Also, add the random to it so the same images will not show up all the time. look further down the mod topic to find the random addition
Buddy Duke
www.budduke.com