PDA

View Full Version : snippets.php question


dscottf
5th of August 2004 (Thu), 13:39
is there a way to get random thumbs from (only) the most recent exhibition, without specifying the exhibition number?

I tried:
http://photo.fx4.net/gallery/snippets.php?get=random_photos&amount=10&exhibitio n=latest_galleries&border=0&viewas=image&thumbsize =microthumb

but that didn't work. I guess what is needed is a function for exhibition= that returns the most recent exhibition

what I would like is for this to be the same as:
http://photo.fx4.net/gallery/snippets.php?get=random_photos&amount=10&exhibitio n=40&border=0&viewas=image&thumbsize=microthumb

and when I make a new exhibition, it acts like it increments to the new one.

or even better, the most recently modified exhibition (which would usually be the same)

I can fake it by manually entering the exhibition number, bit that isn't elegant and I would like it to be maintenance free

usage is at http://www.fx4.net

dscottf
11th of August 2004 (Wed), 10:54
got it working, took a php/mysql expert (that would not be me)

using the newer code Pekka posted here: http://photography-on-the.net/forum/showthread.php?t=29440&postdays=0&postorder=asc&hi ghlight=snippets+php&start=30

replace

if ($exhibition == "all") $exhibition = $all_exhibitions_combined;

$exhib_where = "";

if ($exhibition != $all_exhibitions_combined) {
$exhib_where = " AND ee_exhibition.ee_exhibition_id = {$exhibition} ";
}


with

//Begin latest_ex mod

$exhib_where = "";


if ($exhibition == "7777777") {
$exhibition = $all_exhibitions_combined;
// because $exhibition never == "all" at this point
// the function $exhibition = $all_exhibitions_combined makes $exhibition be 7777777, this needs to be here


} elseif ($exhibition == "latest_ex") {
$query = "Select MAX(ee_exhibition_{$lang}.ee_exhibition_id) AS max_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";
$result = mysql_query($query);
if (!$result) {
print mysql_error();
}
$result_row = mysql_fetch_assoc($result);
$max_id = $result_row['max_id'];
$exhib_where = " AND ee_exhibition.ee_exhibition_id = {$max_id} ";

// if $exhibition == "latest_ex", get highest (max_id) numbered exhibition

} else {
$exhib_where = " AND ee_exhibition.ee_exhibition_id = {$exhibition} ";
// if $exhibition is a NOT "latest_ex" and is a number NOT 7777777, use it
}

// end mod



now when you get=random_photos using exhibition=latest_ex, you get random photos from the highest numbered exhibition. I don't know what it woud do if that exhibition was hidden and you did not specify a password.

try it out at:
http://photo.fx4.net/gallery/snippets3.php?get=random_photos&amount=4&exhibitio n=latest_ex&border=0&viewas=image&thumbsize=thumb