|
Posted by Robin on 04/15/06 20:25
Hi,
this seems to be a Smarty-related problem, I guess, since e.g.
print "<label id='lblSession{$MyID}'>";
$MyID++;
print "<label id='lblSession{$MyID}'>";
works.
Sad but true, I don't have any experiences with Smarty, but what about a
{$MyID++}? Like
{if $wantdebug}
..... code omitted, from block included above ................
{$MyID++}
...
{/if}
Arthur Dent wrote:
> Hello all, sorry for the cross-post, but im not sure which group is best for
> this question.
>
> I am an ASP.NET developer, but am learning PHP/perl for the first time now
> to make some to changes to a client's site which was done by someone else.
>
> I wrote a debug TPL which ive got working great now and was Such a sense of
> accomplishment!! :) . People always say how cryptic C can be, but i think
> perl definitely beats C out! Anyway.... In the
> /classes/com/<site>/runtime/Page.class.php i have some code which reads
> whether the user has requested debug mode and presets some variables for the
> debug.tpl i wrote. Here is the code i have in my Page.class file:
>
> $smarty->assign("wantdebug","0");
> if(isset($_REQUEST['debug'])){
> $smarty->assign("wantdebug","1");
>
> $smarty->assign("sesobj",$_SESSION);
> < above line repeated for $_PUT, $_GET and $_COOKIE >
> }
>
> The following code is the code of my debug.tpl. Everything from the opening
> B tag to the final BR tag is repeated over for the $_PUT, $_GET and $_COOKIE
> smarty variables set up in the Page.class.
>
> {if $wantdebug}
> <div style="background-color: white; border: solid 1px black;
> padding=3px;">
> <b style="cursor: hand;"
> onclick="javascript:document.all['lblSession'].style.display=(document.all['lblSession'].style.display=='none')?'':'none';"><session></b>
> <label id='lblSession' style="display: none;"><br>
> {foreach from="$sesobj" key="key" item="value"}
> {$key}=={$value|replace:"<br>":"|"}<br>
> {foreachelse}
> no session items<br>
> {/foreach}
> <b></session></b>
> </label><br>
> </div>
> {/if}
>
> This all works fine and dandy, and the "<session>" text in the B tag acts as
> a nice little toggle switch to hide show the array contents, like the way
> the little +/- signs do in IE when viewing a raw XML file.
>
> Now here comes my problem.... I want to include the TPL at both the top and
> the bottom of my pages, so that i can see the contents of all the variables
> before and after the page has done all its processing to see how things have
> been affected. But now when i refer to document.all['lblSession'] there are
> two of them on the page. So what i want to do is to have a variable which i
> can append to the label tag's id attribute to make unique ids, such as
> "lblSession1" and "lblSession2". How can i do this? I though i could create
> a variable in the Page.class code, then use it in the TPL something like
> id='lblSession{$MyID}' . Then update the variable in each inclusion of
> the header so each time through the label's ID would be unique based on this
> variable, but i cant seem to get the variable to update. What i tried are
> the couple following things, but none worked.....
> any help how to do this? Thanks in advance!!!
>
> 1st tried:
> <label id='lblSession{$MyID++}' style="display: none;">
>
> 2nd tried:
> {if $wantdebug}
> ..... code omitted, from block included above ................
>
> {php}
> $MyID++
> {/php}
> {/if}
>
> 3rd tried:
> {if $wantdebug}
> ..... code omitted, from block included above ................
>
> {php}
> $smarty->assign("MyID",$MyID+1)
> {/php}
> {/if}
>
>
[Back to original message]
|