View Full Version : Random Image in Index.php
SleepingWolves
12-12-2006, 03:01 AM
Is it possible to configure Index.php so that pixelpost displays a random image each time it is served?
I know there is a random image addon...but I'm not looking to create a link...i want the random image at startup.
thanks
It is possible. Put PP to subdirectory called i.e. photoblog or blog and in root dir put index.php script which reads content of pixelpost's images directory and takes random item from it.
SleepingWolves
12-12-2006, 09:38 PM
Does anyone have a script that will allow this?
Preferably not from the root - I'm alreading using an index.php in the root..i would like to modify PP's index.php so that it points to a random file (with or without the random addon).
When the user clicks on the photoblog link from my wordpress blog it would open to a random image in Pixelpost.
Thanks
Dennis
12-13-2006, 03:20 PM
In that case why not use a index2.php for the link in wordpress and let this index2.php call the index.php with a random photo.
I can write a simple php script if you're interested.
[edit]
I've written a script for this. http://foto.schonhose.nl/index2.php will show a random image.
So the wordpress link would be http://yourblog/index2.php and it will take people to your pixelpost displaying a random image.
I've attached the script as a zip-file to this message. Enjoy!
GeoS, your solution could also work but this seems easier. :D
SleepingWolves
12-13-2006, 10:35 PM
I've written a script for this.
Thank you so much! That is greatly appreciated.
I just got home and uploaded it.
You can see it by clicking on Nature or Travel.
from the link below:
http://www.sleepingwolves.com/blog/?page_id=53
:)
Little addition - besides index2.php add following line to .htaccess file in root folder:
DirectoryIndex index2.php
Thus, any visitor to yoursite.com/ will be automatically showed a randow img.
Dennis
03-02-2007, 06:16 AM
This is not what you want. The normal photoblog will not be accessible anymore if you do this.
Is there any way to integrate the index.php and the index2.php into the same file? All Pixelpost is refered to index.php and when some goes to my website I don't want to tell them to go to http://mywebsite.com/index.php just, mywebsite.com. Thanks and sorry if it is a silly question...
jaywilliams
08-31-2007, 03:07 PM
You can use mod_rewrite.
Open up the .htaccess file in the root pixelpost folder and add this code:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^$ index2.php [L]
You'll want to remove this line:
DirectoryIndex index2.php
index2.php should be the random script, and index.php should be the standard pixelpost file.
When someone goes to example.com index2.php will load.
However if someone goes to example.com/?showimage=1 or example.com/index.php?showimage=3, index.php will load.
Thanks for the info, but I've already done it (my way, maybe the hardest, but the easiest one for a subrookie level progammer)
Renamed:
index.php to home.php
index2.php to index.php
And I made a search and replace from index.php to home.php in:
image_template
browse_template
about_template
/Addons/paged_archive
/Addons/photoblink_thumbs
Also I needes to replace index.php for home.php in the index2.php file...
And it WORKED!!!
foureyedgirl
01-30-2009, 06:19 PM
Ok, I'm totally lost as to what to do. I want to use a random image on page entry too. What, step by step, is the easiest way I can do this (I'm a newbie and not program savy)
Thanks!
AlanC
03-28-2009, 07:56 AM
Dennis - Dropped your index2.php in the root folder of my v1.7.1 PP gallery (the same folder that contains index.php, right?) and get the SQL errors below. I can go to the index.php and all is fine. Where did I goof? The gallery is off the "A Bit of my Work" link here (http://www.alancolephotography.com).
Thanks!
Alan
Warning: Missing argument 1 for start_mysql(), called in /data/18/1/102/34/1754686/user/1896278/htdocs/ACP-SITE/portfolio/index2.php on line 38 and defined in /data/18/1/102/34/1754686/user/1896278/htdocs/ACP-SITE/portfolio/includes/functions.php on line 492
Warning: Missing argument 2 for start_mysql(), called in /data/18/1/102/34/1754686/user/1896278/htdocs/ACP-SITE/portfolio/index2.php on line 38 and defined in /data/18/1/102/34/1754686/user/1896278/htdocs/ACP-SITE/portfolio/includes/functions.php on line 492
Dennis
03-28-2009, 09:11 AM
that code was written for 1.6 and not updated for 1.71.
AlanC
03-28-2009, 06:38 PM
Thanks.
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.