Updating a variable, in a TPL file?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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:


    < 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;  
         <b style="cursor: hand;"  
         <label id='lblSession' style="display: none;"><br>
         {foreach from="$sesobj" key="key" item="value"}
              &nbsp;&nbsp;&nbsp;&nbsp;no session items<br>

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'     . 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' style="display: none;">

2nd tried:
{if $wantdebug}
    ..... code omitted, from block included above ................


3rd tried:
{if $wantdebug}
    ..... code omitted, from block included above ................


Re: Updating a variable, in a TPL file?


this seems to be a Smarty-related problem, I guess, since e.g.

print "<label id='lblSession'>";


print "<label id='lblSession'>";


Sad but true, I don't have any experiences with Smarty, but what about a  
? Like

{if $wantdebug}
      ..... code omitted, from block included above ................



Arthur Dent wrote:
Quoted text here. Click to load it

Site Timeline