In .tpl files bestaat de mogelijkheid om een <!-- INCLUDE include.php --> tag te gebruiken (gevonden in usercomment op php manual). Zie ook onderstaande voorbeeld
index.php
index.tpl
include.php
is het echter mogelijk om de waarde van include.php ook mee te geven via $template->setVariable?
Ik heb al geprobeerd met ipv include.php {FOO} en FOO te gebruiken in de tpl file en dan de variable FOO te zetten. Dit had echter geen resultaat.
index.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
| <?php require_once "IT.php"; $template = new HTML_Template_IT("./"); $template->loadTemplatefile("index.tpl", true, true); $template->setCurrentBlock("ALL"); $template->setVariable("ABOVE", "<p>above</p>"); $template->setVariable("BELOW", "<p>below</p>"); $template->parseCurrentBlock(); $template->show(); ?> |
index.tpl
HTML:
1
2
3
4
5
6
7
8
9
| <html> <body> <!-- BEGIN ALL --> {BELOW} <!-- INCLUDE include.php --> {ABOVE} <!-- END ALL --> </body> </html> |
include.php
HTML:
1
| <p>foo</p> |
is het echter mogelijk om de waarde van include.php ook mee te geven via $template->setVariable?
Ik heb al geprobeerd met ipv include.php {FOO} en FOO te gebruiken in de tpl file en dan de variable FOO te zetten. Dit had echter geen resultaat.