|
I'm following up on my last post with some lessons learned en route to getting random images on the opening page to work correctly. I found the original 08-27-2007 post by iaredatsun that had a 1-line index.php hack that worked perfectly for me in 1.7.1. The full text is below to save you looking around, but I modified line 428 instead of 333. To find the line, I searched index.php for the string
$row = sql_array("SELECT * FROM
and replaced the first occurrence of the entire row containing that partial statement with
$row = sql_array("SELECT * FROM ".$pixelpost_db_prefix."pixelpost WHERE datetime<='$cdate' ORDER BY rand() asc limit 0,1");
FWIW, I use a customized badarrow template, Ajax Categories Manager, External App Upload (for LR) and ImageCycle. All coexist happily with this hack. I saw it in the thread and got the same results in that randomization does not work while I'm logged in as admin, but starts immediately after I log out. I'm happy with that and am not going to look for the line that is called when I'm logged in.
Thanks iaredatsun!
****Original Post Text***
Old 08-27-2007, 05:20 AM
iaredatsun Offline
forum loafer
Join Date: Aug 2007
Posts: 6
A simple random front page image hack
Problem: showing a random picture each time the home page is first loaded.
(Of course this should not effect the loading of images from the browse page.)
I know this has been discussed before but no one seemed to come up with a satisfactory answer to this functionality. Usually people suggested some modification of the site structure with index2.php and random folder image method.
My method is a simple one line modification to the index.php file
line 333 of orginal index.php -
change:
$row = sql_array("SELECT * FROM ".$pixelpost_db_prefix."pixelpost WHERE datetime<='$cdate' ORDER BY datetime DESC limit 0,1");
to:
$row = sql_array("SELECT * FROM ".$pixelpost_db_prefix."pixelpost WHERE datetime<='$cdate' ORDER BY rand() asc limit 0,1");
This will only effect the page when it loaded with no PHP arguments - i.e. only when someone first goes to the site and not when things are accessed from the thumbnails page.
Please note that I think this will only work if you are not logged in as admin. I think modifying that would be simple too.
I'm totally new to this but I have tested this a few times and it seems to work fine - at least for me. Any comments?
Mr.Datsun
__________________
|