@@ -, +, @@ and itemtypes --- Koha/Template/Plugin/Branches.pm | 13 ++++++++++--- Koha/Template/Plugin/ItemTypes.pm | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) --- a/Koha/Template/Plugin/Branches.pm +++ a/Koha/Template/Plugin/Branches.pm @@ -27,11 +27,18 @@ use C4::Koha; use C4::Context; use Koha::Libraries; +our %branches; + +sub new { + my ($class, $context, @params) = @_; + bless { + map { $_->{branchcode} => $_ } @{Koha::Libraries->search()->unblessed} + }, $class; +} + sub GetName { my ( $self, $branchcode ) = @_; - - my $l = Koha::Libraries->find($branchcode); - return $l ? $l->branchname : q{}; + return $self->{$branchcode}->{branchname} // $branchcode; } sub GetLoggedInBranchcode { --- a/Koha/Template/Plugin/ItemTypes.pm +++ a/Koha/Template/Plugin/ItemTypes.pm @@ -24,13 +24,22 @@ use base qw( Template::Plugin ); use Koha::ItemTypes; +our %itemtypes; + +sub new { + my ($class, $context, @params) = @_; + bless { + map { $_->{itemtype} => $_ } @{Koha::ItemTypes->search_with_localization()->unblessed} + }, $class; +} + sub GetDescription { my ( $self, $itemtypecode, $want_parent ) = @_; - my $itemtype = Koha::ItemTypes->find( $itemtypecode ); + my $itemtype = $self->{$itemtypecode}; return q{} unless $itemtype; my $parent; - $parent = $itemtype->parent if $want_parent; - return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; + $parent = $self->{$itemtype->{parent_type}} if $want_parent; + return $parent ? $parent->{translated_description} . "->" . $itemtype->{translated_description} : $itemtype->{translated_description}; } sub Get { --