Date: 06/06/01
- Next message: Steve Edberg: "Re: [phplib] tempnam() function problem (resolved)"
- Previous message: Ignatius Teo: "Re: [phplib] Which M to FR"
- In reply to: Tanya Brethour: "[phplib] set_block problems"
- Next in thread: Dima Nemchenko: "Re: [phplib] set_block problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Tanya,
Wednesday, June 06, 2001, 3:58:57 AM, you wrote:
TB> Things to note.. the set_block call is within a function. The first time I
TB> call this function.. it works fine with no error. The second time the
TB> function is called.. I get the "not a valid handle" error. Why does this
TB> error occur when I call the function multiple times?
When set_block() is called at the first time, the block is removed
from the template, replaced with a variable placeholder with the
block's name. E.g. if you define a block, say 'title':
<!-- BEGIN title -->
...some stuff ...
<!-- END title -->
with the first $tpl->set_block('page', 'title'), all the stuff above
is replaced with {title}, and the contents of the block is saved in
another variable, which would be parsed, if parse('title', 'title')
is called.
That's why there are no such a block after first set_block().
Why do you need to call set_block() multiple times at all?
TB> example function:
TB> function title_bar ($header="", $center=0) {
TB> global $title_tpl;
TB> if (empty ($title_tpl)) {
TB> $title_tpl = new Template ("/usr/local/MHonArc/PHP/", "keep");
TB> $title_tpl->set_file ("page", "title_bar.tpl");
TB> }
TB> if (!$header) {
TB> return blank_bar ();
TB> }
TB> $title_tpl->set_var (array (
TB> "HEADING" => $header));
TB> if ($center) {
TB> $title_tpl->set_var (array ('ALIGN' => "center"));
TB> }
TB> else {
TB> $title_tpl->set_var (array ('ALIGN' => "left"));
TB> $title_tpl->set_block('page', 'title');
TB> $title_tpl->pparse('out', 'title');
TB> }
-- Best regards, Maxim Derkachev mailto:max.derkachev <email protected> System administrator & programmer, Symbol-Plus Publishing Ltd. phone: +7 (812) 324-53-53 www.books.ru, www.symbol.ru--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: Steve Edberg: "Re: [phplib] tempnam() function problem (resolved)"
- Previous message: Ignatius Teo: "Re: [phplib] Which M to FR"
- In reply to: Tanya Brethour: "[phplib] set_block problems"
- Next in thread: Dima Nemchenko: "Re: [phplib] set_block problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

