<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I have blocks called "Related Blogs" or "Related
Videos" etc, which list other nodes of the same type if they've been tagged with
the same terms. It's working great, just that the block is showing even when
there are no related nodes. What I would like is for the block not to show if
there are no related nodes.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My code is:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><div
style="font-size:0.75em;padding:3px;"><BR><!-- 4 returned for each term,
ordered by nid descending, meaning new will always be at top
--><BR><?php<BR>if (arg(0) == 'node' && is_numeric(arg(1))
&& is_null(arg(2))) {<BR> $nid = (int)arg(1);<BR> $terms =
taxonomy_node_get_terms($nid);<BR> $output = "<span
class='whole-list'>";<BR> foreach($terms as
$term){<BR> $sql = "SELECT n.title, n.nid FROM {node} n INNER
JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term->tid AND n.nid !=
$nid ORDER BY RAND() LIMIT 3"; <BR> $result =
db_query(db_rewrite_sql($sql));<BR> if (db_num_rows($result))
{<BR> $output .="<h5
style='color:#900;font-weight:bold;margin-top:3px;'>$term->name</h5><ol
class='each-term'>";<BR> while ($anode =
db_fetch_object($result)) {<BR>
$output .= "<li>".l($anode->title,
"node/$anode->nid")."</li>";<BR> }
<BR> $output.="</ol>";<BR>
}<BR> }<BR> $output .= "</div>";<BR> return
$output;<BR>}<BR>?><BR></div></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>and for the moment, the block visibility is set as
blog/*, video/*, image/*, etc. How can I use php visibility settings to test to
see if any content is returned. Would something as simple as:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>if $output</FONT></DIV>
<DIV><FONT face=Arial size=2>return TRUE</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>work?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Neil</FONT></DIV></BODY></HTML>