Re: [phplib] Template Problems From: Dima Nemchenko (Dima.Nemchenko <email protected>)
Date: 06/09/01

Peter Bowyer wrote:

> Hi,
>
> I have the following code which is supposed to replace a block in my code
> with nothing (ie remove it ;-)) but it doesn't work :-(
>
> Please help, 'cause what I'm doing hinges on getting this to work!
>
> Thanks
> Peter.
> === Start of code ===
> $tpl = new Template(".");
> $tpl->set_file(array("message" => "$template.tpl", "card" => "card.tpl"));
>
> $tpl->set_var("IMAGE", $image);
> [snip]
> $tpl->set_var("MUSIC", $music);
> if ($music == "") {
> $tpl->set_block("message", "music_block");
> $tpl->set_var("music_block", "");
> // $tpl->parse("music_block", "");
> }
>
> $tpl->parse("CONTENT", "message");
> $tpl->pparse("CONTENT", "card");
>
> ======
> Where $music comes from the form input on the page before.
> The number of variables present in this code has been drastically reduced
> for these examples!
> message.tpl contains the following:
>
> [snipped to save space]
> <.image src="{IMAGE}">
> <!-- BEGIN music_block -->
> <object id="sound" classid="clsid:05589FA1-C356-11CE-BF01-00AA0055595A"
> align="baseline" border="0" width="0" height="0">
> <param name="ShowDisplay" value="0">
> <param name="ShowControls" value="1">
> <param name="ShowPositionControls" value="0">
> <param name="ShowSelectionControls" value="0">
> <param name="ShowTracker" value="0">
> <param name="MovieWindowSize" value=0>
> <param name="FullScreenMode" value="0">
> <param name="MovieWindowWidth" value="0">
> <param name="MovieWindowHeight" value="0">
> <param name="AutoStart" value="1">
> <param name="AutoRewind" value="1">
> <param name="PlayCount" value="1">
> <param name="SelectionStart" value="0">
> <param name="Appearance" value="1">
> <param name="BorderStyle" value="0">
> <param name="FileName" value="music/{MUSIC}">
> <param name="DisplayMode" value="0">
> <embed src = "music/{MUSIC}" autostart="true" hidden="true" loop="true">
> </embed>
> <!-- END music_block -->
>
> === end of code ===

Hi Peter,

What you're doing _should_ work. I think the problem might be in the
parse+print stage: try using parse() and then p(), instead of pparse(), 'cos
(if memory serves) pparse() doesn't finish() the variables due to a bug.

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."