Hi Lori,

In your loop where you are pushing onto @loop_data, you'd want to add an
additional variable to your hashref that will indicate whether or not is
drillable. So inside your loop, you might do something like this:


for (some_loop_condition) {
    if (row_is_drillable) {
        push @loop_data, {id => $this,
                          rowname => $that,
                          drillable => 1}
    } else {
        push @loop_data, {id => $this,
                          rowname => $that,
                          drillable => 0}   
    }
}
$tmpl->param(LOOP_DATA => [EMAIL PROTECTED]);


Then inside your template:
<TMPL_LOOP NAME=LOOP_DATA>
    ID:         <TMPL_VAR NAME=ID><br>
    Name:       <TMPL_VAR NAME=ROWNAME><br>
    Drillable?: <TMPL_IF NAME=DRILLABLE>Yes<TMPL_ELSE>No</TMPL_IF>
</TMPL_LOOP>

Basically, you can use TMPL_IF on any variable in your loop. Although, if a
drillable row requires a URL or some other bit of information, you can get away
without an explicit drillable variable and use the presence or absence of the
URL to indicate if the row is drillable.

Remember what true and false are in perl and that will help you. False is 0
(the numeric value), "0" (a string containing the number 0), undef (undefined)
or a empty string ('' or ""). Anything else is true. And that's how
HTML::Tempalte works, as well, when dealing with TMPL_IF.

Clear as mud, right? :) Hope this helps.

Good luck!
--Joel

>I've read the documentation sections on TMPL_IF and TMPL_ELSE.  The part
>where I'm getting stuck is figuring out how to set up that "BOOL" value.  I
>know if "BOOL" is true, then the section in TMPL_IF is run; if it's false,
>the section in TMPL_ELSE is run.  This sounds like what I want to do (I
>think...).
> 
>I have my results generated and the web page looks nice.  However, there are
>some rows that need to have a different bit of HTML in it (some rows/cells
>are to be "drillable" and some are not).  Unfortunately, it's not just the
>"last" or "first", etc.; the rows are interspersed in no particular order,
>some are contiguous, some are stand-alone.
> 
>This is where I get stuck.  I can tell where I am in Perl when I'm pushing
>the hash references to the @loop_data (which is subsequently pushed to the
>template for output), so I can set a variable to something at that time.  
> 
>How do I set up a variable that the TMPL_IF and TMPL_ELSE can use to
>determine which section of the HTML loop to process?
> 
>I hope this made sense.  When you're new, sometimes it's hard to know even
>how to ask a question!  :-)
> 
>Thanks!
> 
>Lori
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Finance: Get your refund fast by filing online


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to