Date: 06/06/01
- Next message: Adam Robertson: "RE: [phplib] L.A.M.P. hosting"
- Previous message: Paul Campbell: "Re: [phplib] L.A.M.P. hosting"
- In reply to: Tanya Brethour: "[phplib] set_block problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tanya Brethour wrote:
> Ok, I have been searching the archives for some help with my error, but
> the solutions I have found.. do not seem to work quite right...
>
> So.. please excuse me if I am repeated a common question.
>
> I am getting errors such as this:
> Template Error: loadfile: title is not a valid handle.
> Halted.
>
> I do have a title block in my template file.
>
> Things to note.. the set_block call is within a function. The first time I
> call this function.. it works fine with no error. The second time the
> function is called.. I get the "not a valid handle" error. Why does this
> error occur when I call the function multiple times?
>
> *snip*
Hi Tanya,
Maxim is right. Just call set_block() once, when you "initialise" the page.
Then call set_var() and parse() on the block within the function(s):
function setTitle($i) {
$template->set_var("title_text","$i");
$template->parse("title_item","title",true);
}
...
$template=new Template();
$template->set_file("PAGE","index.ihtml");
$template->set_block("PAGE","title","title_item");
for ($i=0;$i++;$i<10) {
setTitle($i);
}
$template->parse("Output","PAGE");
$template->p("Output");
...
(WARNING: I haven't tried this actual code! There might be syntax errors ;)
Hope this helps,
--:D_ima Dima Nemchenko <Dima.Nemchenko <email protected>>
"Open source code is like lobster--most people who haven't tried it don't like the way it looks. But those who try it, love it."
- Next message: Adam Robertson: "RE: [phplib] L.A.M.P. hosting"
- Previous message: Paul Campbell: "Re: [phplib] L.A.M.P. hosting"
- In reply to: Tanya Brethour: "[phplib] set_block problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

