Hi folks,

In attempting to print this hash of hashrefs I read this:
http://template-toolkit.org/pipermail/templates/2002-April/003056.html

and emulated it in the code below.  When I run this I get $class{'id'}
but none of the values from the hashref it contains.  I also tried this
without using import() and accessing the values as $id.name to the same
result.

What am I dong wrong?  Using Dumper I can see that the data I want is in
my hashrefs.

TIA,

David


Perl:

# get array of this educator's classes as $obj
my @class_objects = AIOC::Class->search(educator => $educator_id);

# make hash for template
my %classes;
foreach (@class_objects) {
    $classes{$_->{'id'}} = {   name            => $_->{'name'},
                               beginning_grade =>
$_->{'beginning_grade'},
                               ending_grade    => $_->{'ending_grade'},
                  };
}


return $self->render_page('cp/cp_index.html', { 
                                       educator_id    => $educator_id, 
                                       classes        => \%classes });


Template:

[% IF classes %]
   [% FOREACH id = classes.keys %]
       [% import(classes.$id) %]
           <li><a href="class.pl?id=[% id %]&rm=activate">[%
name%]</a></li>
   [% END %]

[% ELSE %]
        You must create a class before you can activate its session.
[% END %]




All you have to do is decide
what to do with the time that
is given to you.
                      ~ GTG




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

Reply via email to