By: Fabrizio Lodi
Wrong order of template content after show ?!?I create my final template through multiple "LoadTemplate" commands (all except the first with a "+" instead of the charset).
Let's say I load a "head.tm", then a "main.htm" and finally a "tail.htm".
Both head and tail templates uses a custom tag linked to a function
to include css or js content with a programmatic constructed file name, checking before that the file exist:
I use the tag 2 times, one at the end of "head.htm":
And one in "tail.htm":
All works great, the only things is that in the final page I get both the files where in "tail.htm" I call the function, and not one ad the end of "head.htm" and one in "tail.htm" as expected.
Re: Wrong order of template content after show ?!?Hi Fabrizio,
The point is that your function getInclude() should not drive the template. It should only return the result of the content for the field.
So there should be no « $app["TBS"]->Source.=$c; » nor « $app["TBS"]->LoadTemplate(null); ».
The double content you've got is because of that: inserted once by the function, and once by TBS.
Considering your previous post, I guess you're doing this for merging fields in your sub-templates.
For inserting your JS ans CSS contents, did you try with TBS sub-templates ?
Something like this :
This will insert the sub-template, merge [onload] fields in the sub-template. It will delete the <script> entity if value of "js" is empty, thanks to parameter "magnet".
If you actually need to drive the merging of sub-template, then it is better to use parameter "onformat" with parameter "subtpl".
This enables you to call a PHP function where the scope of TBS is only for the sub-template.