Hi,
I have finished what I had talked about above and would like to share it now for inspiration to others.
I have created a custom function which permutes through all existing combination's of two tags, searches for matching images and if at least one is found it will
then create a dynamic album called 'tag1 & tag2'.
At the moment it is set to recreate every hour (called from header.php), not because of new tags but the SQL also shuffles the order in which they are created and so the album page varies nicely.
potentially once I start being LIVE with ZP I will properly ,for the sake of speed, limit the album creation to minimum of 3 or more matching images.
But till now it works nicely
Have a look: http://www.dev.bregler.net/gallery
function produce_dynalbums($path = '') {
$path = $_SERVER["DOCUMENT_ROOT"].$path;
$Diff = (time() - filemtime("$path/portraits.alb"))/60/60;
if ($Diff > 1) // 1 hour
{
foreach (glob($path."*.alb") as $filename) {
unlink($filename);
}
$result = mysql_query("select count(*) as hitcount, t3.name,t4.name from (SELECT distinct t1.objectid, t1.tagid as tag1,t2.tagid as tag2 FROM zp_obj_to_tag as t1 left join `zp_obj_to_tag` as t2 on t1.objectid=t2.objectid and t1.id>t2.id and t2.type='images' where t1.type='images' ) dbr left join zp_tags t3 on dbr.tag1=t3.id left join zp_tags t4 on dbr.tag2=t4.id left join zp_images as i on dbr.objectid=i.id where title is not NULL group by t3.name,t4.name order by rand()");
$dbfields = array();
while ($row = mysql_fetch_row($result)) {
$fileContainer = $path.$row[1];
if ($row[2]) $fileContainer = $fileContainer."_".$row[2];
$fileContainer = $fileContainer.".alb";
$filePointer = fopen($fileContainer,"w+");
$fileContent = "WORDS=".$row[1];
if ($row[2]) $fileContent = $fileContent." AND ".$row[2];
$fileContent = $fileContent."\n";
fputs($filePointer,"$fileContent");
fputs($filePointer,"THUMB=\n");
fputs($filePointer,"FIELDS=tags\n");
fclose($filePointer);
}
}
}