473,654 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("wantde bug","0");
if(isset($_REQU EST['debug'])){
$smarty->assign("wantde bug","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="backgrou nd-color: white; border: solid 1px black;
padding=3px;">
<b style="cursor: hand;"
onclick="javasc ript:document.a ll['lblSession'].style.display= (document.all['lblSession'].style.display= ='none')?'':'no ne';">&lt;sessi on&gt;</b>
<label id='lblSession' style="display: none;"><br>
{foreach from="$sesobj" key="key" item="value"}
&nbsp;&nbsp;&nb sp;&nbsp;{$key} =={$value|repla ce:"<br>":"|"}< br>
{foreachelse}
&nbsp;&nbsp;&nb sp;&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
"lblSession 1" and "lblSession 2". 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 3434
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("wantde bug","0");
if(isset($_REQU EST['debug'])){
$smarty->assign("wantde bug","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="backgrou nd-color: white; border: solid 1px black;
padding=3px;">
<b style="cursor: hand;"
onclick="javasc ript:document.a ll['lblSession'].style.display= (document.all['lblSession'].style.display= ='none')?'':'no ne';">&lt;sessi on&gt;</b>
<label id='lblSession' style="display: none;"><br>
{foreach from="$sesobj" key="key" item="value"}
&nbsp;&nbsp;&nb sp;&nbsp;{$key} =={$value|repla ce:"<br>":"|"}< br>
{foreachelse}
&nbsp;&nbsp;&nb sp;&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
"lblSession 1" and "lblSession 2". 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
985
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
1591
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 int NOT NULL, N2 int NOT NULL) UPDATE @t SET N1 = (SELECT COUNT(1) FROM @t AS t WHERE t.N2 < @t.N2)
1
5946
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 updating files with about 60 to 200 rows, we get the
10
5802
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: WebForm1.aspx ChangeValue.aspx WebUserControl1.ascx Module1.vb
6
4067
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 lost. So i have to provide some lock mechanism to that file in ftp, so how can i lock it, if one client opens it for updating, so that till it gets relased it cannot be updated by other clients. Could u please suggest me the simple solutions...
3
2469
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 problem is I don't see the items added to the listbox unless I use
3
2682
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 value changed, it will be saved to the same line and file. The problem is the line of (WARPFREQ = 0.88) was deleted and the updated line from the process (WARPFREQ = 1.28) was inserted without shifting the below line. Additionally, the incremental...
4
7606
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 like numbers etc. Anyway, i'm just updating the field properties like lblnumber.Text = variable1; Now the weird thing is that...when i run the app and it cycles through
0
889
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, both print statements print "20" as I'd expect. I take it you do have a *really* good reason to use a global? --
0
8372
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.