Categories > TinyButStrong general >

onload in sub templates

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Nick
Date: 2008-07-01
Time: 10:50

onload in sub templates

Hi everyone,
I tried finding any relevant info but I couldn't. So the manual states that TBS does not process [onload] fields in subtemplates (those that were loaded using [onload] themselves)

Is there any way to change this behaviour? I have subtemplates within subtemplates and I'm not sure how to find a way around this issue...

Thanks
By: Nick
Date: 2008-07-01
Time: 10:56

Re: onload in sub templates

Sorry, one clarification - the idea here is to put different blocks dynamically on the page depending on a number of factors (user enables, disables the box etc...) Since it's not possible to specify an array of strings for the "file" parameter, I made a function that constructs a string of the form "[onload;file=file1][onload;file=file2]" ... then I put this string into a subtemplate this way:

[var.mystring;protect=no] which outputs the string itself but doesn't process the TBS instructions

Any tips would be appreciated, since this template engine is by far the most intuitive both for me and the designers *thumbsup*
By: Skrol29
Date: 2008-07-02
Time: 19:12

Re: onload in sub templates

Hi,

The manual says [onload] tags are not processed inside sub-templates, but it is not true. They are actually processed. I will update the manual.

You can cook your dynamic subfile insertion without coding tags in the PHP side.
Examples:
HTML
<div> [special;file=[f.val;block=div]] </div>
PHP:
$TBS->MergeBlock('file',$filelist);
$TBS->MergeField('special','');

MergeField() merges all [special] fields with value '', whatever the value, the field merging makes the file insertion.
By: Nick
Date: 2008-07-02
Time: 20:22

Re: onload in sub templates

Wow thanks, that works! You are the man Skrol :)
By: Skrol29
Date: 2008-07-03
Time: 00:39

Re: onload in sub templates

The following should work too (not tested):
HTML:
<div> [f.val;block=div;file=[val]] </div>

PHP:
$TBS->MergeBlock('f',$filelist);