On Fri, 19 Sep 2003, Mace, Richard wrote:

> Hi,
> I have a hash in my CGI script, e.g. $info{$filename} = $filepath; 
> (hash contents e.g. 
> KEY: one.html,   VALUE: /REPORTS
> KEY: two.html,   VALUE: /REPORTS
> KEY: three.html, VALUE: /REPORTS
> KEY: four.html,   VALUE: /REPORTS ).
> 
> I'm passing the $info hash to my tt2 script and in this script I have ...
> 
> [% FOREACH project = info %]
>       <A HREF="[% project.value %]/[% project.key %]">[% project.key %]
> [% END %]

You might try the 'sort' vmethod. From Template::Manual::VMethods :

  sort, nsort
    Return a list of the keys, sorted alphabetically (sort) or numeri-
    cally (nsort) according to the corresponding values in the hash.

        [% FOREACH n = phones.sort %]
            [% phones.$n %] is [% n %],
        [% END %]

So in your case, this would probably be:

  [% FOREACH project = info.sort %]
      <A HREF="[% info.project %]/[% project %]">[% project %]
  [% END %]

HTH,

Simon

-- 
"My name ? My name is Slartibartfast."
 


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to