By: Michaelsen
Date: 2011-05-21
Time: 18:48
|
file or subtpl as string
Dear Skrol29,
I'm not being able to achieve the following:
//PHP SIDE
$tbsfile = "
<div>
[cats.cat_id;block=div]
</div>
";
|
//HTML SIDE
[onload;file=$tbsfile]
|
It will not find the file, as I assume it shouldn't.
If I do as follow:
[var.tbsfile;htmlconv=no;protect=no]
|
It won't work as it should, if I hardcode $tbstable in the html side, it will work fine.
As you can see I'm lost.
Is it simple to have a string as a subtpl? I guess this is what I'm trying to do.
What I was working on was a function that automates the construction of the navbar according to the block name, so I can only worry with the css side every time I need to paginate a tbs block. I got stuck in this part where I'm trying to bring the html side from a string, for the moment it is working fine since the function will write the string into a text file and then it is included with onload;file. But I would prefer it coming from a string.
Regards,
- Michaelsen
|
By: Skrol29
Date: 2011-05-24
Time: 00:40
|
Re: file or subtpl as string
> It will not find the file, as I assume it shouldn't.
Of course, because $tbsfile is not a file path.
> It won't work as it should, if I hardcode $tbstable in the html side, it will work fine.
The field [var.tbsfile;htmlconv=no;protect=no] is merged at the end of the merge, i.e. when you call $TBS->Show().
Replace it with: [onload.tbsfile;htmlconv=no;protect=no]
|
By: Michaelsen
Date: 2011-05-24
Time: 16:40
|
Re: file or subtpl as string
Hello again,
Sir, I really appreciate your reply in this manner, but if you allow me I need to bother you a little more.
Unfortunately when I tried your code above I noticed I need to define tbsfile before $TBS->LoadTemplate, as tbs logic says, but this is so inconvenient for me, since it would be so much more pleasant to have the query and the navbar together such as this:
tbsPaginate($tbsBlk,$tbsQry,4);
$tbsfile = tbsNav("items/[var._GET.cat_id]/page",$tbsBlk,5,"centred",1);
|
Should I give up on this and mantain the tbsNav function to harcode the navbar in a file to be included, or is there a way out?
Thank you again!
- Michaelsen
|
By: Skrol29
Date: 2011-05-24
Time: 23:39
|
Re: file or subtpl as string
Hi,
If you need to define $tbsfile after the LoadTemplate() but before the MergeBlock('cat', ...), then you can merge $tbsfile when you need using MergeField, just like this:
PHP side;
$TBS->LoadTemplate(...);
...
$tbsfile = ...
$TBS->MergeField(f1, $tbsfile);
...
$TBS->MergeBlock('cat', ...);
|
HTML side:
[f1;htmlconv=no;protect=no]
|
|
By: Michaelsen
Date: 2011-05-26
Time: 20:27
|
Re: file or subtpl as string
This is so cool!
//TBS block name
$tbsBlk = "cats";
//Build TBS navbar: pathway, block name, visible pages, step, show footer
tbsNav("cat/[var._GET.cat_id]",$tbsBlk,5,"centred",1);
//Build tbs block and paginate results: block name, query, page size
tbsPaginate($tbsBlk,$tbsQry,4);
|
Thank you Mr. Skrol, I think now I have a better hang of MergeField.
As always, TBS is the best php class ever, please keep up the good work sir.
|
|
Posting in progress.
Please wait...
|