PDA

View Full Version : template question for the pros



doron
Sat 1st Jul '00, 5:22pm
on working for the poll hack, I got stuck on this:

In order to let the user define the number of options, I use 2 templates:

newpoll:


<smallfont>Remember to keep the poll options short and to the point</smallfont>

<BR>

<TABLE WIDTH="100%" CELLPADING="0" CELLSPACING="2" BGCOLOR="#FFFFFF">

$pollnewbit

</TABLE>


and newpollbit:



<TR>
<TD><normalfont>Option $run:</normalfont></TD>
<TD><INPUT NAME="Option$run" TYPE="TEXT" sIZE="45"></TD>
</TR>


Now, I want to call newpoll once and newpollbit x times. The following code however, only gives me once newpollbit:



for ($run=1; $run < $PollNum; ++$run){
eval("\$pollnewbit = \"".gettemplate("pollnewbit")."\";");
}
eval("\$pollnew = \"".gettemplate("pollnew")."\";");


What am I doing wrong? Probably something stupid ;)

customcpu
Sat 1st Jul '00, 8:52pm
Actually in PHP

++$a
is the same as

$a++

customcpu
Sat 1st Jul '00, 8:56pm
Almost forgot... There IS a difference between the two - just not in the context that was asked.


$a = 10; // $a is 10
$b = $a++; // $a is 11, but $b is 10 (The assignment occued before the incrementation)

but


$a = 10; // $a is 10
$b = ++$a; // $a and $b are both 11 (The assignment occured after the incrementation

doron
Sun 2nd Jul '00, 5:54am
I solved it myself. should be



for ($run=1; $run < $PollNum; $run++){
eval("\$pollnewbit .= \"".gettemplate("pollnewbit")."\";");
}


anyone know the full meaning of .= in comparison to just a = in templates?

customcpu
Sun 2nd Jul '00, 10:35am
.= appends while = does not. For example:


$a = "hello ";
$a = "world"; // $a is world

while


$a = "hello ";
$a .= "world"; // $a is hello world

Freddie Bingham
Sun 2nd Jul '00, 2:41pm
.= seems to be the equivalent to += in C. I need to look up why they felt the need to use a . to denote addition.

aritus
Sat 15th Jul '00, 3:18am
sorry for my stupid question :(, but idon'n know and really would like to khow about vb template.
what is and wheeis vb template?
thanks :)

doron
Sat 15th Jul '00, 7:10am
a template defines how the page looks like. this means you can alter the look without hacking at the codebase.