Hi all
I've been looking for a way to create a block which will display the latest image uploaded in a particular taxonomy category. So I eventually came up up with the following snippet which does what I want it to do. My question: Surely there's a "proper" Drupal way to do what I am doing? My three sql calls seems a bit wasteful. BTW, I'm not a programmer, so be gentle.
-K.
<?php/*** Display latest image based on a taxonomy category* To change which taxonomy is listed, edit the $taxd_id number.*/$taxo_id = 17;$list_no =1;$image_size="_original";$sql = "SELECT node.title, node.nid FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid = $taxo_id LIMIT $list_no";$result = db_query($sql);while ($anode = db_fetch_object ($result)) { $kp_nid = $anode->nid; }$sql = "SELECT fid FROM image WHERE nid = $kp_nid AND image_size = \"$image_size\" LIMIT $list_no";$result = db_query($sql);while ($anode = db_fetch_object ($result)) { $kp_fid = $anode->fid; }$sql = "SELECT filepath FROM files WHERE fid = $kp_fid LIMIT $list_no";$result = db_query($sql);while ($anode = db_fetch_object ($result)) { $kp_filepath = $anode->filepath; }$output = "<IMG SRC=\"/$kp_filepath\">";return $output;?>
Snippet to get latest image based on taxonomy: Is there a more efficient way to do what I am doing?
Drupal Themes