Bug 24387: Rename "News" with "Additional contents"
[koha.git] / Koha / Template / Plugin / AdditionalContents.pm
1 package Koha::Template::Plugin::AdditionalContents;
2
3 # Copyright ByWater Solutions 2012
4 # Copyright BibLibre 2014
5 # Parts copyright Athens County Public Libraries 2019
6
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22 use Modern::Perl;
23
24 use Template::Plugin;
25 use base qw( Template::Plugin );
26
27 use C4::Koha;
28 use C4::Context;
29 use Koha::AdditionalContents;
30
31 sub get {
32     my ( $self, $params ) = @_;
33
34     my $category   = $params->{category};
35     my $location   = $params->{location};
36     my $blocktitle = $params->{blocktitle};
37     my $lang       = $params->{lang} || 'default';
38     my $library    = $params->{library};
39
40     my $content = Koha::AdditionalContents->search_for_display(
41         {
42             category   => $category,
43             location   => $location,
44             lang       => $lang,
45             library_id => $library,
46         }
47     );
48
49     if ( $content->count ) {
50         return {
51             content    => $content,
52             location   => $location,
53             blocktitle => $blocktitle
54         };
55     }
56 }
57
58 1;
59
60 =head1 NAME
61
62 Koha::Template::Plugin::AdditionalContents - TT Plugin for displaying additional contents
63
64 =head1 SYNOPSIS
65
66 [% USE AdditionalContents %]
67
68 [% AdditionalContents.get() %]
69
70 =head1 ROUTINES
71
72 =head2 get
73
74 In a template, you can get the all categories with
75 the following TT code: [% AdditionalContents.get() %]
76
77 =head1 AUTHOR
78
79 Owen Leonard <oleonard@myacpl.org>
80
81 =cut