Categories > TinyButStrong general >

magnet on automatic subblock

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2010-09-13
Time: 03:15

magnet on automatic subblock

Hello,
My first attempts at automatic subblocks is almost working.

But... I cannot find how to get magnet to work to delete the table holding the subblock when the subblock field (an array) is null (or empty).

I also had to hack the subblock array to be and empty string instead of null array to eliminate the error messages for null value but didn't eliminate the empty table either.

Here's my template - do you see anything I am missing???
((I just know it's me and not a TBS bug!!!))

<tr><td bgcolor="#f4f4f4" class="name" >[blkcat.name;block=tr;sub1=offices_array;htmlconv=no;noerr]

   <table summary="" width=100% bgcolor="#ffffff" border=0 cellspacing=0>
   <tr><td>
   * <font style="font-size: 11;"> [blkcat_sub1.region;block=tr;magnet=table;noerr] Region: [blkcat_sub1.city;htmlconv=no;noerr] [blkcat_sub1.state;noerr] [blkcat_sub1.phone;noerr]</font> 
   </td></tr>
   </table>
  
</td></tr>

Thanks for any help you can give,
TomH
By: Skrol29
Date: 2010-09-13
Time: 09:40

Re: magnet on automatic subblock

Hi,

Use bmagnet for blocks instead of magnet.
By: TomH
Date: 2010-09-13
Time: 12:43

Re: magnet on automatic subblock

Well,
About bmagnet... perhaps I misunderstand the usage you intend, but...
For me this does NOT work
<td  class="name" >
<font style="font-size: 16px;font-weight: bold; line-height: 1.6em;">[blkcat.name;block=tr;sub1=offices_array;htmlconv=no;noerr]</font>
<p style="color: Navy; font-size: 12px; line-height: 1.5em; margin-left: 5px; margin-top: 1px; margin-bottom: -5px;">
<a href="mailto:[blkcat.email;htmlconv=no;noerr]">[blkcat.email;htmlconv=no;noerr]</a> <a href="http://[blkcat.website;htmlconv=no;noerr]" target="link">[blkcat.website;htmlconv=no;noerr]</a><br>
<city>[blkcat.city;bmagnet=city;htmlconv=no;noerr],</city>
<state>[blkcat.state;bmagnet=state;htmlconv=no;noerr]</state>
<phone><br>[blkcat.phone;bmagnet=phone;htmlconv=no;noerr] tel</phone>
</p>
This does work
<td  class="name" ><!-- bgcolor="#e6dcff" #f4f4f4 -->
<font style="font-size: 16px;font-weight: bold; line-height: 1.6em;">[blkcat.name;block=tr;sub1=offices_array;htmlconv=no;noerr]</font>
<p style="color: Navy; font-size: 12px; line-height: 1.5em; margin-left: 5px; margin-top: 1px; margin-bottom: -5px;">
<a href="mailto:[blkcat.email;htmlconv=no;noerr]">[blkcat.email;htmlconv=no;noerr]</a> <a href="http://[blkcat.website;htmlconv=no;noerr]" target="link">[blkcat.website;htmlconv=no;noerr]</a><br>
<city>[blkcat.city;magnet=city;htmlconv=no;noerr],</city>
<state>[blkcat.state;magnet=state;htmlconv=no;noerr]</state>
<phone><br>[blkcat.phone;magnet=phone;htmlconv=no;noerr] tel</phone>
</p>


I was able to remove the table that wraps the automatic subblock by adding a dummy
wrapper block around it and use a magnet on the subblock field, not pretty -- see below..
<offices>
<!--  [blkcat.offices_array;magnet=offices;mtype=m*m;noerr] -->
<table summary="" width=100% bgcolor="#ffffff" border=0 cellspacing=0>
<tr><td style="font-size:9px;"> <font style="color:red;">*</font>
<font style="text-align:center; color: Navy; font-size: 9px;">
[blkcat_sub1.region;block=tr;noerr] Region: [blkcat_sub1.city;htmlconv=no;noerr]
[blkcat_sub1.state;noerr] [blkcat_sub1.phone;noerr]</font></td></tr>
</table>(
</offices>

But, unhappily, in order to prevent the error message:
"TinyButStrong Error when merging block [blkcat_sub1] : unsupported variable type : 'NULL'."
I still needed to hack the returned subblock array to be empty like this...
foreach($result AS $k=>$val){
    if($val['offices_multival']!=""){
    $result[$k]['offices_array'] = my_stripslashes(unserialize($val['offices_multival']));
    }else{
    $result[$k]['offices_array'] =""; // need this to remove errors from null array
    }
    }

Any ideas for doing this more correctly?

Thanks,
TomH
By: Skrol29
Date: 2010-09-14
Time: 00:26

Re: magnet on automatic subblock

Hi TomH,

bmagnet is a parameter for block, it works only in the same TBS tag that has the parameter "block=".
Try with something like this:
  <table summary="" width=100% bgcolor="#ffffff" border=0 cellspacing=0>
    <tr>
      <td style="font-size:9px;">
      <font style="color:red;">*</font>
      <font style="text-align:center; color: Navy; font-size: 9px;">
        [blkcat_sub1.region;block=tr;bmagnet=table;noerr] Region: [blkcat_sub1.city;htmlconv=no;noerr]
        [blkcat_sub1.state;noerr] [blkcat_sub1.phone;noerr]
      </font>
      </td>
    </tr>
  </table>
By: TomH
Date: 2010-09-14
Time: 07:12

Re: magnet on aumagnet does not event the tomatic subblock

I did understand (surprised!), I had coded as you indicated but when the the _sub1 field is null that record kicks out the dreaded
"TinyButStrong Error when merging block [blkcat_sub1] : unsupported variable type : 'NULL'." error.

The main records defined by [blkcat.name;block=tr;sub1=offices_array;htmlconv=no;noerr] from the query all exist,
but the field "offices_array" is sometimes NULL -- that is the problem. 

As I mentioned it is possible to work around this situation but I wanted to make sure there was not something I am
overlooking (or maybe this is something that would be fixed in a future release?). Don't mean to be beating a dead horse, sorry.

Sincerely,
TomH


By: Skrol29
Date: 2010-09-14
Time: 09:31

Re: magnet on aumagnet does not event the tomatic subblock

Ok,

You're right, TBS should handle null values as an empty source for automatic sub-block. TBS 3.6.0 is about to be released, so I'll can fix before the final.
Until this fix, you can use parameter "ondata" to replace any null value with an empty array.