@@ -, +, @@ --- Koha/Template/Plugin/Context.pm | 47 ++++++++++++++++++++++ .../prog/en/includes/catalog-strings.inc | 8 +++- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 Koha/Template/Plugin/Context.pm --- a/Koha/Template/Plugin/Context.pm +++ a/Koha/Template/Plugin/Context.pm @@ -0,0 +1,47 @@ +package Koha::Template::Plugin::Context; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use base qw( Template::Plugin ); + +use C4::Context; + +=head1 NAME + +Koha::Template::Plugin::Scalar - Return object set in scalar context + +=head1 SYNOPSIS + +If you need to force scalar context when calling a method on a object set. +Especially useful to call ->search + +=cut + +=head1 API + +=head2 Class Methods + +=cut + +sub Scalar { + my ( $self, $set, $method ) = @_; + $set = $set->$method; + return $set; +} + +1; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc @@ -1,3 +1,4 @@ +[% USE Context %]