@@ -, +, @@ descriptions for template plugin --- Koha/Template/Plugin/ItemTypes.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/Koha/Template/Plugin/ItemTypes.pm +++ a/Koha/Template/Plugin/ItemTypes.pm @@ -22,15 +22,32 @@ use Modern::Perl; use Template::Plugin; use base qw( Template::Plugin ); +use Koha::Cache::Memory::Lite; use Koha::ItemTypes; sub GetDescription { my ( $self, $itemtypecode, $want_parent ) = @_; + return q{} unless defined $itemtypecode; + + my $memory_cache = Koha::Cache::Memory::Lite->get_instance; + my $cache_key = $want_parent ? "Itemtype_parent_description:".$itemtypecode : "Itemtype_description:" . $itemtypecode; + + my $cached = $memory_cache->get_from_cache($cache_key); + return $cached if $cached; + my $itemtype = Koha::ItemTypes->find( $itemtypecode ); - return q{} unless $itemtype; + unless ($itemtype) { + $memory_cache->set_in_cache( $cache_key, q{} ); + return q{}; + } + my $parent; $parent = $itemtype->parent if $want_parent; - return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; + + my $description = $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; + $memory_cache->set_in_cache( $cache_key, $description ); + + return $description; } sub Get { --