By: Piotr Budny
Date: 2007-08-01
Time: 14:37
|
codeigniter + onload subtemplates
I use TBS with CodeIgniter. I've got main template:
<h1>[vars.header] / [vars.filename] </h1>
[onload;file=[vars.filename]]
|
When rendering in browser I see:
TinyButStrong Error in field [onload...] : the file '[vars.filename]' given by parameter file is not found or not readable. This message can be cancelled using parameter 'noerr'.
My Real header / page.html
|
The variables are set up by:
$this->data['header'] = "My Real header";
$this->data['footer'] = "My Real foot";
...
$this->data['filename'] = 'page.html';
$this->tbswrapper->tbsMergeField('vars', $this->data);
$this->tbswrapper->tbsMergeBlock('query', $query);
|
If I change the template to:
[onshow;file=[vars.filename]]
|
the subtemplate is included, but the blocks are not processed (it shows, that the file IS readable and onshow works, because it doesn't process blocks, as manual says).
Moreover, when I do touch '[vars.filename]' (create literally that file) in my project, the content of that literal file IS readed in browser...
Besides, when I do:
the sub template is included and blocks are processed.
So the question is, why TBS can't include that file with onload method and [vars.filename] variable? Why it searches for literally '[vars.filename]' file?
The variable IS set, look at the template's <h1> tag.
Regards
vip
|
By: Skrol29
Date: 2007-08-02
Time: 19:31
|
Re: codeigniter + onload subtemplates
Hi Piotr Budny,
All this seems normal.
- [onload] tags are merged when LoadTemplate is running.
- [vars] tags are merged when MergeField('vars',...) is running.
- [query] tags are merged when MergeBlock('query',...) is running.
- [onshow] tags are merged when Show() is running.
So when [onload] tags are processed, [vars] tags are not yet merged and TBS doesn't know it will be merged next. So TBS tries it as a file name.
You can do this :
[vars.filename;file=[val]]
|
|
By: Piotr Budny
Date: 2007-08-03
Time: 00:06
|
Re: codeigniter + onload subtemplates
It works!
It is always better to know what are You doing, not just doing it...
Thanks!
BTW. Isn't a bit strange? You just can't merge fields/blocks before LoadTemplate, right?
Regards,
vip
|
By: Skrol29
Date: 2007-08-03
Time: 01:07
|
Re: codeigniter + onload subtemplates
> BTW. Isn't a bit strange? You just can't merge fields/blocks
> before LoadTemplate, right?
No you can't.
[onload] fields are merged just when it is loaded (just after).
|
By: Piotr Budny
Date: 2007-08-03
Time: 15:51
|
Re: codeigniter + onload subtemplates
Unfortunately, there's another problem.
The sub template is loaded, blocks are processed; but at the end of sub-template there is simple array read:
(i've tried more variables from "vars" array) merged before MergingBlock
$this->tbswrapper->tbsMergeField('vars', $this->data);
$this->tbswrapper->tbsMergeBlock('query', $query);
|
So as I can see, the "vars" field is lost.
If I add "links" field after the block:
$this->tbswrapper->tbsMergeField('vars', $this->data);
$this->tbswrapper->tbsMergeBlock('query', $query);
$this->tbswrapper->tbsMergeField('links', $this->data);
|
the [links.filename] works.
What's happened with "vars" after merging "query" block?
|
By: Piotr Budny
Date: 2007-08-03
Time: 15:54
|
Re: codeigniter + onload subtemplates
I didn't mentioned, that the vars.filename is not interpreted,
it is literally displayed as [vars.filename].
|
By: Skrol29
Date: 2007-08-06
Time: 11:41
|
Re: codeigniter + onload subtemplates
Hi,
The command tbsMergeField('vars') merges the [vars] fields in the main template, if this merging brings new [vars] fields, they are not merged in the same time.
I guess if you do
$this->tbswrapper->tbsMergeField('vars', $this->data);
$this->tbswrapper->tbsMergeField('vars', $this->data);
|
then your [vars] fields will be merged in the sub-template too.
|
|
Posting in progress.
Please wait...
|