473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Updating a variable, in a TPL file?

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';">&lt;session&gt ;</b>
<label id='lblSession' style="display: none;"><br>
{foreach from="$sesobj" key="key" item="value"}
&nbsp;&nbsp;&nbsp;&nbsp;{$key}=={$value|replace:"< br>":"|"}<br>
{foreachelse}
&nbsp;&nbsp;&nbsp;&nbsp;no session items<br>
{/foreach}
<b>&lt;/session&gt;</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}
Apr 15 '06 #1
1 3422
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';">&lt;session&gt ;</b>
<label id='lblSession' style="display: none;"><br>
{foreach from="$sesobj" key="key" item="value"}
&nbsp;&nbsp;&nbsp;&nbsp;{$key}=={$value|replace:"< br>":"|"}<br>
{foreachelse}
&nbsp;&nbsp;&nbsp;&nbsp;no session items<br>
{/foreach}
<b>&lt;/session&gt;</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}

Apr 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rajarshi Guha | last post by:
Hi, I have been translating some Algol code to python and am facing a problem. Heres an example of the code: def f(x): print 'hello' c =0 def g(y):
7
by: Dimitri Furman | last post by:
What would be the correct syntax, if any, that allows updating a table variable in a statement that uses the same table variable in a correlated subquery? Here's an example: DECLARE @t table (N1...
1
by: Srinadh | last post by:
Hi all, We have files with about 20 to 30 fields per row. We are trying to update such files with about 60 rows as contiguous data in a CLOB field. It passes through. But when we try...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
6
by: muttu2244 | last post by:
hi all am updating the same file in ftp, through multiple clients, but am scared that two clients may open the same file at a time, and try updating, then the data updated by one data will be...
3
by: R. Harris | last post by:
Hi. I have 2 forms: form1 form2 On Form2 I have a listbox and a button. When I click the button it calls a function from form1 and within that function it updates the listbox on form2. My...
3
by: indra061 | last post by:
Hi all, I am newbie of perl. The story is, i need to read and update one variable from text file (WARPFREQ = 0.88). The value of WARPFREQ will be inceremented by 0.2 up to 1.2. Everytime the...
4
by: directory | last post by:
hey guys, I've got a weird one for ya....i have a form which takes user input in the form of textbox's etc. It then grabs some details from a file and updates some of the labels with some info...
0
by: Tim Rowe | last post by:
2008/9/24 <dudeja.rajat@gmail.com>: I'm surprised it runs at all -- as far as I can see "mod" in "mod.update(a)" and "print mod.a" is not defined. Did you mean "mod1"? If I change it to that,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.