PDA

View Full Version : random photos AND latest photos on EE index page


okapi
27th of February 2004 (Fri), 05:49
Dear Pekka, i know, you have plenty of coding work to do... but... may i ask you again to do me a favour?

On my EE index page i would like to have not only "some random photos" as i have have so far, but ALSO the thumbs of the latest three photos (in order of the exhibition).

You helped me so kindly with the code for a link to the latest photo, which you coded with a "latest.php". Could you please help me (and maybe others who are interested in) with a code?

This is the last feature left on my personal EE wishlist. Right now i'm updating the latest thumb by hand, but i would love to let EE doing this.

my photolog is a result of some layout modifications i've made so far:

http://www.a-visual-notebook.at/

michael

Ewan
27th of February 2004 (Fri), 09:38
I changed latest.php a little as follows to make it display a thumbnail and called it displaylatest.php. I'm no php/sql expert and I don't understand 80% of the code in there so it is probably a bit messy:

<?php

include ("toroot.php");
include ($toroot . "add/connect.php");
include ($toroot . "language.php");
include ($toroot . "slashwork.php");
$getlang = $toroot . "languages/" . $lang . "/global.php";
include($getlang);

if (!isset($pass)) {
$pass = "public";
}
if (isset ($HTTP_GET_VARS['exhibition'])) {
$exhibition = $HTTP_GET_VARS['exhibition'];
}
if (!isset ($HTTP_GET_VARS['exhibition'])) {
include ("add/allowedexhibitions_sql.php");
@$valid = $allowedexhibs[0][0];
$exhibition=$valid;
}

include ("fetchsettings.php");


$exhibs = mysql_query(
"
SELECT
ee_exhibition_{$lang}.ee_exhibition_name,
ee_exhibition_{$lang}.ee_exhibition_id
FROM
ee_exhibition_{$lang},
ee_exhibition
WHERE
ee_exhibition.ee_exhibition_pass = 'public'
AND ee_exhibition.ee_exhibition_id = ee_exhibition_{$lang}.ee_exhibition_id
ORDER BY
ee_exhibition_{$lang}.ee_exhibition_id DESC
LIMIT 5
"
);
if (!$exhibs) {
print mysql_error();
}

$basics = mysql_query( "
SELECT
ee_photo.ee_photo_id,
ee_photo_{$lazylang}.ee_photo_header,
ee_photo_{$lazylang}.ee_photo_text,
ee_photo.ee_photo_exif_datetime,
ee_photo.ee_photo_filename
FROM
ee_photo_{$lazylang} USE INDEX (ee_photo_id),
ee_photo USE INDEX (ee_photo_id),
ee_photo_to_exhibition,
ee_exhibition
WHERE
ee_photo.ee_photo_for_www = 'yes'
AND ee_photo_to_exhibition.ee_photo_id = ee_photo.ee_photo_id
AND ee_photo_to_exhibition.ee_exhibition_id = ee_exhibition.ee_exhibition_id
AND ee_exhibition.ee_exhibition_pass = '$pass'
AND ee_photo.ee_photo_id = ee_photo_{$lazylang}.ee_photo_id
ORDER BY
ee_photo.ee_photo_id DESC
LIMIT 1
"
);
if (!$basics) {
print mysql_error();
}
?>




<?php

ob_start();


print "<b>Latest photo:</b>";
while ($row = mysql_fetch_array($basics)) {
$thumb = $row["ee_photo_filename"];
$header = ee_stripslashes($row["ee_photo_header"]);
$id = $row["ee_photo_id"];
print "<br><a href=\"photo.php?photo={$id}\"><img src=\"images/thumb/{$thumb}\" border=\"0\" alt=\"{$header}\"></a>";


}
$display_photos = ob_get_contents();
ob_end_clean();

?>


<?php
mysql_close();
?>


and then called it as follows:


include("displaylatest.php");
print $display_photos;

Ewan
27th of February 2004 (Fri), 09:41
You'll need to make sure the path to your thumbs is correct in line 86, as I'm sure it isn't the same as mine.

okapi
27th of February 2004 (Fri), 11:15
thank you very much, ewan,
unfortunately it does not work. i have put displaylatest.php to my root and the code

<?php
include("displaylatest.php");
print $display_photos;
?>

on indexfiles/1.php

but all i get is:

Fatal error: Cannot redeclare ee_addslashes() (previously declared in /home/.sites/69/site292/web/slashwork.php:22) in /home/.sites/69/site292/web/slashwork.php on line 22

any idea why?

Ewan
29th of February 2004 (Sun), 07:47
Sorry, no. I don't remember getting that error message when I did it.

okapi
29th of February 2004 (Sun), 12:13
did you really put

<?php
include("displaylatest.php");
print $display_photos;
?>

into ../indexfiles/1.php ?

and did you place displaylatest.php at the root?

Ewan
1st of March 2004 (Mon), 06:49
I put displaylatest.php and the file calling it (newindex.php) in the root of my gallery. I didn't edit 1.php.