By: Anonymous
Date: 2016-03-12
Time: 19:35
|
sub template with some parametersScroll,
I have made a lot of progress thanks to the pointers you have given me. You will probably answer yes to this question as well... is it possible to use a sub template with some parameters. I think this is what 'subtpl' is for. What I want to do is to put some conditional and often reused TBS stuff inside it, and then just get the merged data back. I want to use it to format the output strings depending on the type of data it represents. So if it is a float, i will present it with the 0.1234 format, if integer, with the frm='0' parameter. So to the sub template I want to pass the datatype of the item, the raw string and then get back the merged and formatted string. Roughly the stuff I want to put in the template are below. I want to pass it a type string, in this case the [constants.const_type] and the data string, in this case [constants.const_defaultvalue] and then just merge back the result. Possible? Pointers in the right direction?
|
||
By: Skrol29
Date: 2016-03-14
Time: 23:18
|
Re: sub template with some parametersHi Ivor,
Using sub-template is done for re-use a piece of template. But in your case I generally use another technical: parameter "ondata". Since your parts are quite similar and are place inside the same block, here is what you can do: At PHP side, use an "ondata" function to customize data beofre merging.
And at the template side :
By the way, did you know "block=_" and "block=!div" ? They are spacial marks that can facilitate you block bounding. See http://www.tinybutstrong.com/manual.php#html_block_prm_specialmarks |
||
By: Ivor
Date: 2016-03-17
Time: 21:43
|
Re: sub template with some parametersScroll, thanks again for replying, i missed this reply because it went to "anonymous" for some reason. I will try it out as soon as possible.
Ivor |
||
By: Ivor
Date: 2016-03-22
Time: 08:03
|
Re: sub template with some parametersScroll, your on_data function works perfectly, of course. Thanks again.
Oh, I just changed the line that had
to
Ivor |