Categories > TinyButStrong general >

on data not working in subblocks?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Francois
Date: 2011-04-12
Time: 17:24

on data not working in subblocks?

I'm trying to merge a sub block with an ondata function, but it does not work. It's displaying this warning:
"Warning: Parameter 2 to get_field_label() expected to be a reference, value given in tbs_class_php5.php on line 382"

Does it make sense? and how can I fix it?
By: Skrol29
Date: 2011-04-12
Time: 20:54

Re: on data not working in subblocks?

The syntax of you custom ondata function must have a special definition.
See: http://www.tinybutstrong.com/manual.php#html_block_prm_ondata
By: Francois
Date: 2011-04-13
Time: 09:13

Re: on data not working in subblocks?

Thanks Skrol29, but I already used some ondata functions in other templates, and I think I used the right syntax, especially as I'm using the same function in another part of the same template, and it's working fine ! So it must be related to the fact that I'm trying to apply it in a subblock maybe ?

By: Skrol29
Date: 2011-04-13
Time: 23:15

Re: on data not working in subblocks?

The error message says that your function should have a declaration with &$CurrRec instead of $CurrRec ($CurrRec is the second argument of the function).
By: Francois
Date: 2011-04-14
Time: 08:36

Re: on data not working in subblocks?

Yes I know, I did that, but it's still not working. The function is working fine in other blocks, and I checked the syntax.
By: Skrol29
Date: 2011-04-15
Time: 21:41

Re: on data not working in subblocks?

Can you send to me a piece of code that would reproduce the error ?
The I could explore for debugging.
By: Francois
Date: 2011-04-18
Time: 14:39

Re: on data not working in subblocks?

Sure, no problem.
Here is the template part:

<div> <b>[filter_title.label;block=div;htmlconv=no;bmagnet=div]</b>
<ul>
    <li>
    <a name="filter[[filter_title.field]]=[filtervalue_top5.field;block=li;p1=[filter_title.field];ondata=changelabel;bmagnet=((div))]" class="filter_change2">[filtervalue_top5.label] ([filtervalue_top5.quantity])</a>
    </li>
</ul>
</div>

The PHP code:
$TBS->MergeBlock('filter_title','array',$tebusearch->filters_name);   
$TBS->MergeBlock('filtervalue_top5','array','filterstop5_list[%p1%]');

I display a list of filters, with a list of values for each filter. I want to apply the function on the subblock (the list of values), so that I can change the .label value.
I found another solution by using the onformat parameter, but I had to use a ugly trick to do so. So if ondata could work on subblocks, it would be cleaner I think.

Thanks for looking at it !
By: Skrol29
Date: 2011-04-24
Time: 00:32

Re: on data not working in subblocks?

hi Francois,

I cannot reproduce your bug.
Can you also send an ondata function that reproduce the bug?