<!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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>My code is:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&lt;div 
style="font-size:0.75em;padding:3px;"&gt;<BR>&lt;!-- 4 returned for each term, 
ordered by nid descending, meaning new will always be at top 
--&gt;<BR>&lt;?php<BR>if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1)) 
&amp;&amp; is_null(arg(2))) {<BR>&nbsp; $nid = (int)arg(1);<BR>&nbsp; $terms = 
taxonomy_node_get_terms($nid);<BR>&nbsp; $output = "&lt;span 
class='whole-list'&gt;";<BR>&nbsp; foreach($terms as 
$term){<BR>&nbsp;&nbsp;&nbsp; $sql = "SELECT n.title, n.nid FROM {node} n INNER 
JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term-&gt;tid AND n.nid != 
$nid ORDER BY RAND() LIMIT 3";&nbsp; <BR>&nbsp;&nbsp;&nbsp; $result = 
db_query(db_rewrite_sql($sql));<BR>&nbsp;&nbsp;&nbsp; if (db_num_rows($result)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $output .="&lt;h5 
style='color:#900;font-weight:bold;margin-top:3px;'&gt;$term-&gt;name&lt;/h5&gt;&lt;ol 
class='each-term'&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ($anode = 
db_fetch_object($result)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
$output .= "&lt;li&gt;".l($anode-&gt;title, 
"node/$anode-&gt;nid")."&lt;/li&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $output.="&lt;/ol&gt;";<BR>&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp; }<BR>&nbsp; $output .= "&lt;/div&gt;";<BR>&nbsp; return 
$output;<BR>}<BR>?&gt;<BR>&lt;/div&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>work?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Neil</FONT></DIV></BODY></HTML>