SysAdm has asked for the wisdom of the Perl Monks concerning the following question:

After a TMPL_LOOP, I would like to only display once if NAME is true. Instead, display is multiple due to every occurrence it finds to be TRUE in the LOOP. How do I get around this...? I only want to display once if found.

Example:
<TMPL_LOOP NAME"CATEGORIES"> <TMPL_IF NAME="HIGH PRIORITY">DISPLAY 'HIGH' </TMPL_IF> </TMPL_LOOP>

This will display 'HIGH' every time it finds a TRUE occurrence... I only want to display 'HIGH' once!

Any help would be greatly appreciated...

Replies are listed 'Best First'.
Re: TMPL LOOP question
by wjw (Priest) on Jan 29, 2011 at 05:57 UTC
    Based on what I am reading here in HTML::Template Tutorial under Example 3, I think you are going to need to ensure that you are not getting duplicates while generating the array of hashes that gets passed to the loop. I don't see how the TMPL_LOOP combined with a conditional would allow you to do this in the template itself.

    I could of course be wrong, and would be happy to have anyone point it out if I am.

    • ...the majority is always wrong, and always the last to know about it...
    • The Spice must flow...
    • ..by my will, and by will alone.. I set my mind in motion