I've made Plogger random thumbnails display on the front page using the code below. Clicking on the images takes you right to it's location in the album flawlessly. Credit to theg3nius for posting the code over here --> http://theg3nius.com/wordpress/2005/10/10/plogger-add-in-script/ for me to tinker with.
<?php $host="hostname"; $username="username"; //Database username here $password="dbpassword"; //Database password here $database="dbname"; //Database name here $amount="6"; //How many images do you want shown? $siteurl="http://yoursite.com/ploggerdirectory"; //The URL of your Plogger directory E.G. http://yoursite.com/ploggerdirectory ***IMPORTANT*** DO NOT INCLUDE A TRAILING SLASH LIKE THIS http://yoursite.com/ploggerdirectory/
$q = "SELECT * from plogger_pictures order by RAND() LIMIT $amount"; $result= mysql_query($q) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $path=$row["path"];
It greatly improves legibility and keeps it less prone to server config frustrations.
Secondly, if you are going to use shorttags, I would suggest using ASP-style with the "=" sign.
Keeping in mind this is almost all stylistic, and doesn't affect page rendering that much (although echo() does take execution time, and multiple calls take more, afaik).
What a great little script. Thanks for sharing it. Is it possible to have it display random images within a specific album?
For example, if my Plogger had two albums; Vacations and Cats, and I had two sections on my site dedicated to Vacations and Cats, I'd like to pull random cat images in the cats section and random vacation images from the vacation section.
An easy workaround would be to just set up two Ploggers, for each album and use two copies of this script to pull from each database. That's doable, but it would be nice to see if this can pull random images from one database based on category/album title.
ddejong sorry but im learning php where i can do your change "First, I would suggest getting rid of your shorttags, and also enveloping the whole snippet into one echo statement.
Much of this can be eliminated. Here's how I would do it. Create a new file in the same directory as your index.php and gallery.php called random.php, with this code.
http://rafb.net/paste/results/4I8Mny67.html
Then, just add the following where you want them to be displayed in your index.php page. <? include('random.php'); ?>
I love this script and am using it at http://cathcoll.net. Question - for a new site I'm developing, is there a way to pull a random image rather than a random thumbnail? I tried a couple of things but being a PHP cluebie, none of them worked.
Great script, I've put it to use on livingos.com by wrapping it in my first wordpress plugin.
This is very rough still and very much work-in progress as I'm new to WP and Plogger.
I did find a WP plugin for plogger here somewhere, but it wasn't complete and didn't seem to do anything. Anybody know if this has been completed anywhere?