By: phg
Date: 2012-10-22
Time: 17:20
|
MergeField with userfunctionHello,
I have a problem understanding MergeField with a MySQL-query and a userfunction. I have a database which contains records with fields, which I want to modify before output. May be, I am on a total wrong way. I think, can use a function, which makes the modification. First question: Must I call the MergeField-call before or after the MergeBlock-Call? Second question: What is the correct syntax calling my function? I looked for e complete example, but I dont find one. Here is my code:
And here is the template test.htm:
Many thanks for help. phg |
||
By: Skrol29
Date: 2012-10-23
Time: 02:57
|
Re: MergeField with userfunctionHi phg,
In your snippet, the line with MergeField() will have no effect because there is no "table_data" fields left in the template. They all were already merged by MergeBlock(). If you want to catch the data before to merge them. They are two possibilities. 1) Fetch yourself the SQL data in a php variable such as $data. Change the data. Then merge the variable with a MergeBlock(). or 2) Use parameter "ondata" on the block. This enables you to define a custom PHP function that can read and modify each records before it is merged. See http://www.tinybutstrong.com/manual.php#html_block_prm_ondata |