@@ -, +, @@ --- C4/NewsChannels.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/C4/NewsChannels.pm +++ a/C4/NewsChannels.pm @@ -211,9 +211,29 @@ sub GetNewsToDisplay { my $sth = $dbh->prepare($query); $lang = $lang // q{}; $sth->execute($lang,$branch); + + my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; + my $template = Template->new( + { + EVAL_PERL => 1, + ABSOLUTE => 1, + PLUGIN_BASE => 'Koha::Template::Plugin', + COMPILE_EXT => $use_template_cache ? '.ttc' : '', + COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', + FILTERS => {}, + ENCODING => 'UTF-8', + } + ) or die Template->error(); + my @results; while ( my $row = $sth->fetchrow_hashref ){ $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); + + my $content = $row->{content}; + my $output; + $template->process( \$content, {}, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error(); + $row->{content} = $output; + push @results, $row; } return \@results; --