Hello all,
Hi all,
I'm having a problem using global variables inside my loops. I have
global_vars => 1 in my H::T constructor, but it's not working in nested
loops.
Detail:
I'm working on a script that will display a list of products (TMPL_LOOP).
Within each product in that loop, I am displaying a drop down box showing
the different sizes available. Within that drop down, I'm showing the price
for each size. Some products have one price for all sizes, and some have a
different price for each size.
This is an example data structure:
$data = {
CATEGORY => 'Uniforms' ,
PRODUCTS => [
{
SINGLE_PRICE => '10.99' ,
SIZE_LIST => [
{ 'SIZE' => 'Small' ,
'INDIVIDUAL_PRICE' => undef() } ,
{ 'SIZE' => 'Large' ,
'INDIVIDUAL_PRICE' => undef() } ,
]
} ,
{
SINGLE_PRICE => undef() ,
SIZE_LIST => [
{ 'SIZE' => 'Small' ,
'INDIVIDUAL_PRICE' => '5.99' } ,
{ 'SIZE' => 'Large' ,
'INDIVIDUAL_PRICE' => '7.99' } ,
]
} ,
]
};
This is an example template:
---snip---
<TMPL_VAR NAME=CATEGORY>
<table>
<TMPL_LOOP NAME=PRODUCTS>
<tr>
<td><TMPL_VAR NAME=CATEGORY></td>
<td>
<select name="size">
<TMPL_LOOP NAME=SIZE_LIST>
<option><TMPL_VAR NAME=SIZE> $<TMPL_IF
NAME=INDIVIDUAL_PRICE><TMPL_VAR NAME=INDIVIDUAL_PRICE><TMPL_ELSE><TMPL_VAR
NAME=SINGLE_PRICE></TMPL_IF>
</TMPL_LOOP>
</select>
</td>
</tr>
</TMPL_LOOP>
The output shows that the CATEGORY variable is visible inside the TMPL_LOOP
for PRODUCTS, but inside the TMPL_LOOP for SIZE_LIST, I can't see
SINGLE_PRICE.
Does that make sense? Any help is appreciated.
Kenny Smith
JournalScape.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]