@@ -, +, @@ - Choose an existing itemtype code (ie DVD) - Edit any template (ie intranet-main.tt) - Add as first line : [% USE KohaAuthorisedValues %] - Add in body : itemtype=[% 'DVD' | $KohaItemType %] - Go to this page --- C4/ItemType.pm | 21 ++++++++++++++++++++ Koha/Template/Plugin/KohaItemType.pm | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Koha/Template/Plugin/KohaItemType.pm --- a/C4/ItemType.pm +++ a/C4/ItemType.pm @@ -87,6 +87,27 @@ sub all { return @itypes; } +=head3 C4::ItemType->new_from_code($code) + +This returns the itemtype as object from code. + +=cut + +sub new_from_code { + my ($class, $code) = @_; + my $dbh = C4::Context->dbh; + my $itype; + my $sth = $dbh->prepare(q{ + SELECT * FROM itemtypes WHERE itemtype = ? + }); + $sth->execute($code); + my $data = $sth->fetchrow_hashref; + if ($data) { + $itype = $class->new($data); + utf8::encode($itype->{description}); + } + return $itype; +} --- a/Koha/Template/Plugin/KohaItemType.pm +++ a/Koha/Template/Plugin/KohaItemType.pm @@ -0,0 +1,36 @@ +package Koha::Template::Plugin::KohaItemType; + +# Copyright 2013 BibLibre SARL + +# 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 2 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +use Template::Plugin::Filter; +use base qw( Template::Plugin::Filter ); +use warnings; +use strict; + +use C4::ItemType; + +sub filter { + my ($self,$code) = @_; + my $itemtype = C4::ItemType->new_from_code($code); + return $itemtype ? $itemtype->description : ''; +} + +1; --