By: TomH
Date: 2006-07-11
Time: 19:18
|
Hiding a block with no data
Hi
Having trouble hiding a block when db query returns no rows
PHP
$sql3 = "select * from index_page WHERE module='block' AND position='top' ";
$query = $db->get_results($sql3); // do the basic query using SQL_CALC_FOUND_ROWS trick
$TBS->MergeBlock('blk_top', $db); |
HTML
<tr>
<td>
Lots of other stuff
</td>
<!-- RIGHT BLOCKS -- none or many db entries -->
<rightblocks>
<td rowspan=99 valign=top width="120">
<table class="rightblocks" width=120 bgcolor="#E4E4E4" cellspacing="0" cellpadding="2" border="1">
<tr><th>[blk_right.descript;block=table]</th></tr>
<tr>
<td bgcolor="#F0F0F0">[onshow;file=[blk_right.url];nodata; magnet=((td))] </td>
</tr>
</table>
</td>
</rightblocks>
</tr> |
Result:
<rightblocks>
<td rowspan=99 valign=top width="120">
</td>
</rightblocks> |
As you can see, the TABLE is gone bit the TD cell remains
Any ideas
|
By: Skrol29
Date: 2006-07-11
Time: 19:29
|
Re: Hiding a block with no data
It looks normal to me. I don't know when "blk_right" is merged, but it is defined on <table>.
By the way: parameter "nodata" defined on the [onshow] tag is ignored.
|
By: TomH
Date: 2006-07-12
Time: 00:41
|
Re: Hiding a block with no data
When I had tried going to the second TD tag outside of the blk def, like this...
<rightblocks>
<td rowspan=99 valign=top width="120">
<table class="rightblocks" width=120 bgcolor="#E4E4E4" cellspacing="0" cellpadding="2" border="1">
<tr><th>[blk_right.descript;block=((td));noerr]</th></tr>
<tr>
<td bgcolor="#F0F0F0">[onshow;file=[blk_right.url];nodata; magnet=((td))] </td>
</tr>
</table>
</td>
</rightblocks> |
I get the error...
TinyButStrong Error in block's definition [blk_right.descript...] : tag <((td))> or </((td))> is not found.
Even though I get this error -- the correct HTML is deleted from the template --but the werror msg prevents me from doing this.
More ideas?
|
By: Skrol29
Date: 2006-07-12
Time: 09:52
|
Re: Hiding a block with no data
"block=((td))" works for TBS 3 only. Could you check you TBS version?
If it's 2.x, it cannot work with this syntax, you have to use the old parameter "encaps".
|
By: TomH
Date: 2006-07-12
Time: 13:02
|
Re: Hiding a block with no data
Yeah,
that's right, am using 3.1.1
Got it working by removing the first "block=((td))" which was breaking the code.
Now have it working this way...
<rightblocks>
<td bgcolor="#F7F7F7" rowspan=99 valign=top width="120">
<table class="rightblocks" width=120 bgcolor="#E4E4E4" cellspacing="0" cellpadding="2" border="1">
<tr><th>[blk_right.descript;noerr]</th></tr>
<tr>
<td bgcolor="#F0F0F0">[onshow;file=[blk_right.url]; magnet=((td));noerr] </td>
</tr>
</table>
</td>
</rightblocks> |
|
By: Skrol29
Date: 2006-07-12
Time: 14:13
|
Re: Hiding a block with no data
Hello TomH,
I can reproduce your error on the previsous snippet, the one with "block=((td))".
The TBS error message was not describing the problem correctly. It fact, TBS cannot found the second level of <td> because your TBS tag is not ebedded into two level of <td>, but into <th> and <td>.
So your block definition should simply be : "block=td".
|
By: TomH
Date: 2006-07-12
Time: 17:13
|
Re: Hiding a block with no data
Thanks for that. Sorry to have been a bother.
The only gain is that you continue to teach us so much about TBS with your careful answers to problems that come from our careless coding errors.
|
|
Posting in progress.
Please wait...
|