Hello,
Yes, i know this is problem has a simple solution but I haven't found it
yet, so maybe you can direct me a little. In apache handler i have this:
$dbh is handler to a database where i get all needed data.
my $vars = {
my_data => \&my_sub($dbh),
};
$template->process($file, $vars, $r) || do {
$r->log_reason($template->error, $r->filename);
return SERVER_ERROR;
};
sub my_sub
{
my $dbh = shift;
my $query = "SELECT id, name FROM table";
my $sth = $dbh->prepare_cached("$query")
or die $log->notice($dbh->errstr);
$sth->execute();
$sth->bind_columns(undef, \$id, \$name);
while( $sth->fetch() ) {
my $data = {};
$data->{id} = $id;
$data->{name} = $name;
push @LoH, $data;
}
return @LoH;
}
Now how can I use this fetched data in my templates? I tried
[% FOREACH temp = my_data %]
[% temp.id %] -> [% temp.name %]
[% END %]
and
[% my_data.size %]
but they're just empty. So I wonder what am I doing wrong? @LoH if filled
with data for sure, I logged it from handler, but i doesn't seem to get to
template :(
Rgds,
Viljo