4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: releasedj on February 07, 2003, 03:00:54 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.
If there are no "new" images, it will display the newest images ordered by date.
At line 81 in index.php (with version 1.7), you will see the following code:
$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 IN (".get_auth_cat_sql("auth_viewcat").")
ORDER BY i.image_date DESC
LIMIT $num_new_images";
If you replace this code with:
$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";
this should do it for you.
Regards,
Kelvin
-
so, what if I want to have One Line of Static images, and one line of Random images? thanks for your help!
-
so, what if I want to have One Line of Static images, and one line of Random images? thanks for your help!
http://www.4homepages.de/forum/viewtopic.php?t=4259
-
good very thk
-
Hmm, I saw no changes with this.
Does it actually display random images, or does it display the 4 latest images, even if they fall off the "new" bandwagon?
Thanks
-
Hmm, I saw no changes with this.
Does it actually display random images, or does it display the 4 latest images, even if they fall off the "new" bandwagon?
yes, this will show random images on index.php from new images. But when no new images avalable, it will show "static" (not random) last added images, insteadof displaying "No new images" as another mod that randomize new images on home page.
-
Oooooooooh, my bad, soowy :oops:
And in that case, can we get the subject of this thread changed?
It does not accurately reflect what the mod does.
Thanks
-
Call me a n00b, cause the only other randomizer I found was this:
http://www.4homepages.de/forum/viewtopic.php?t=1968
Which doesn't do crap if you don't have any new images (see link in sig).
8O Linkify Me Cause I'm Blind 8O
-
yes, thats the mod. that one is older then this one for about 3 month ;)
-
Is there a mod that exists that will display 4 random images if no new images exist?
-
hum...no
-
hum...no
that answer made me look into the code... :lol:
replace: ORDER BY random_no DESC, i.image_date DESC
with: ORDER BY random_no DESC, RAND(), i.image_date DESC
-
Thanks! That works perfectly.
-
well ia dd that mod two nice and short
-
Hey it realy works[/size] :lol:
-
..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
-
..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
-
u can lower your "new images" timeout in the settings ;)
-
that answer made me look into the code... :lol:
replace: ORDER BY random_no DESC, i.image_date DESC
with: 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.
-
nice work I will try it 8)
-
Oh, i added this to 1.7.2, seems to work fine.
$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";
-
hey thanks man, I also added it to 1.7.2 and it works great :D
-
hum...no
that answer made me look into the code... :lol:
replace: ORDER BY random_no DESC, i.image_date DESC
with: 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
-
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.
-
Hahah, awesome! Done it, and love it
-
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.
$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
-
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]
-
Thankx V@no
You are The Guru :D
-
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.
-
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
$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
-
hum...no
that answer made me look into the code... :lol:
replace: ORDER BY random_no DESC, i.image_date DESC
with: ORDER BY random_no DESC, RAND(), i.image_date DESC
This does not work on 1.7.7, no new images appear at all.
-
I have tryed this MOD, but dont get it to work. (4images Version 1.77 but index.php shows version 1.76)
Error:
An unexpected error occured. Please try again later.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /is/htdocs/47852/domainname/media/includes/db_mysql.php on line 116
After login as Admin the error is:
DB Error: Bad SQL Query: SELECT IF(i.image_date >= 1264340208,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, c.cat_name, u.user_name FROM gallery_images i, gallery_categories c LEFT JOIN gallery_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (0, 264, 162, 132, 131, 130, 273, 252, 176, 150, 140, 108, 207, 219, 113, 275, 292, 257, 282, 261, 244, 255, 177, 144, 259, 122, 251, 191, 254, 186, 274, 142, 111, 204, 174, 272, 281, 283, 170, 136, 135, 237, 284, 296, 212, 217, 250, 234, 171, 208, 193, 265, 216, 262, 240, 209, 158, 256, 277, 178, 278, 247, 114, 201, 157, 290, 145, 196, 214, 185, 197, 198, 222, 260, 203, 258, 263, 295, 106, 133, 235, 141, 206, 143, 233, 189, 112, 169, 210, 179, 146, 276, 168, 269, 246, 194, 159, 213, 253, 215, 238, 243, 288, 123, 172, 151, 134, 109, 202, 220, 232, 271, 115, 279, 245, 124, 293, 267, 164, 147, 192, 116, 249, 205, 165, 125, 137, 218, 160, 231, 195, 211, 184, 118, 294, 161, 242, 163, 280, 200, 270, 199, 166, 138, 126, 149, 180, 190, 230, 285, 239, 268, 181, 156, 297, 119, 167, 139, 127, 148, 229, 183, 120, 152, 236, 286, 128, 107, 228, 298, 287, 182, 187, 153, 129, 227, 121, 154, 289, 226, 155, 291, 225, 224, 223) ORDER BY random_no DESC, i.image_date DESC LIMIT 3
Unknown column 'i.user_id' in 'on clause'
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /is/htdocs/47852/domainname/media/includes/db_mysql.php on line 116
No Images are showend
What went wrong?
http://www.4homepages.de/forum/index.php?topic=22668.0? MySQL is V 5.0.32
"If your 4images is newer then v1.7.1 and you still get these errors, then you must have installed a mod that is not MySQL v5 compatible." Does thise mean this MOD is not MySQL v5 compatible? If so how to change the code to work with MySQL v5?
-
change
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
to
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
.. look now...
-
Thank you works perfectly.
Next question:
How to make "Neue Bilder" only be showed if there are new images?
-
this work
http://www.4homepages.de/forum/index.php?topic=4010.msg64771#msg64771
but it's show to me 4 images how i can set it 6 pic ?
-
FAQ -> How can I show more new images on home page? (http://www.4homepages.de/forum/index.php?topic=8946.0)
-
This does not work on 1.7.7
-
This does not work on 1.7.7
try this its work
http://www.4homepages.de/forum/index.php?topic=4010.msg64771#msg64771
-
This does not work on 1.7.7
Whats your MySQL version, you are useing?
MySQL 5?
If so, try: http://www.4homepages.de/forum/index.php?topic=4010.msg145087#msg145087
-
ORDER BY random_no DESC, RAND(), i.image_hits DESC
This rondomize my new images sorted by hits "image_hits" query too... How to randomize only random_no???
-
Does not work with 1.7.10
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.user_name FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER BY random_no DESC, RAND(), i.image_date DESC LIMIT 8
Unknown column 'random_no' in 'order clause'
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/irishavs/public_html/includes/db_mysql.php on line 116
-
Does not work with 1.7.10
.....Unknown column 'random_no' in 'order clause'
you have no column 'random_no' in your DB
this works
http://www.4homepages.de/forum/index.php?topic=4010.msg64771#msg64771
-
Does not work with 1.7.10
It works, you just made a mistake on the first line of the code you were supposed to replace.
-
Thanks Rembrandt it works alright but......
I had 8 images showing to fill the homepage, now i am reduced to 4 again.
-
do you want 8 images only on home.html?
search in the code:
LIMIT $num_new_images";
replace:
LIMIT 8";
mfg Andi
-
Absolutely Perfect!
Thanks!
-
no problem :D