|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Hi,
Works well for me too. Although, I have a link on my front page called "Latest Image", which for now is set with a 'href' point to index.php. If I could change that so that the 'href' really did point to the latest image, that would be ideal. Any ideas? Right now, the URL to my most recent image is: http://domain.com/index.php?showimage=91 So how can I change the 'href' to be a variable that would use the most recent image and use that for my "Latest Image" link? That way, on the initial page load, visitors would get a random image, but when they clicked on "Latest Image" visitors could start from the beginning of the blog. Thanks! -Witty |
|
#3
|
|||
|
|||
|
Quote:
My guess is that you put <SITE_PHOTONUMBER> in your template where the latest photo number should go in your url string. Try that. <SITE_PHOTONUMBER> gets replaced by the number of photos in the database ($pixelpost_photonumb). But I don't know what happens if a photo has been deleted as I don't know if it uses a unique id or a number to retrieve images. That's the current limit of my knowledge. |
|
#4
|
||||
|
||||
|
Hi,
You're definitely on the right track. While <SITE_PHOTONUMBER> is in fact the total number of photos, it is not the unique ID number that is used to identify each photo. The tag we're looking for is <IMAGE_LAST_ID>. I tested it and it works. Thanks iaredatsun! -Witty |
|
#5
|
||||
|
||||
|
Hi,
I'm not sure why yet, but this hack appears to "break" (including my modification to show <IMAGE_LAST_ID>) when you're logged in as Admin and viewing the blog.... works fine otherwise. -Witty |
|
#6
|
|||
|
|||
|
Quote:
I only hacked the section where the user is not logged in as admin. I figured that as admin it may be better to see the latest photo than to keep getting a random image when you are testing the site. |
|
#7
|
||||
|
||||
|
Hi,
It (talking about the <IMAGE_LAST_ID> tag) leaves off the image number in the following URL: http://domain.com/index.php?showimage=91 So it looks like this when it breaks: http://domain.com/index.php?showimage= and says this: Quote:
For me, now that I know WHY it breaks, it doesn't really matter. As long as it works for non-admin visitors, that's all I care about. -Witty |
|
#8
|
|||
|
|||
|
Just wondering.. does this also work with V1.7.1?
(cant find the code used here) |
|
#9
|
|||
|
|||
|
In V1.7.1 at line 424 I see
$row = sql_array("SELECT * FROM ".$pixelpost_db_prefix."pixelpost WHERE datetime<='$cdate' ORDER BY ".$cfgrow['display_sort_by']." ".$display_order." limit 0,1"); Could some one tell me what I need to adjust to get it workin? Thanks. |
|
#10
|
||||
|
||||
|
In v1.7.1 its on Line # 423
__________________
Jay Williams | A Different View |
| Post Reply |
| Thread Tools | |
|
|