1 package Koha::Template::Plugin::KohaPlugins;
3 # This file is part of Koha.
5 # Copyright ByWater Solutions 2018
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use base qw( Template::Plugin );
28 Koha::Template::Plugin::KohaPlugins - A module for adding hooks into Koha for plugins
32 This plugin contains functions related to adding plugin hooks into various parts
35 To use, include the line '[% USE KohaPlugins %]' at the top of the template
40 =head3 get_plugins_opac_head
42 [% KohaPlugins.get_plugins_opac_head %]
44 This method collects the output of all plugins with an opac_head method
45 to output to the head section of opac pages.
49 sub get_plugins_opac_head {
51 unless C4::Context->preference('UseKohaPlugins');
53 my $p = Koha::Plugins->new();
57 my @plugins = $p->GetPlugins(
59 method => 'opac_head',
63 my @data = map { $_->opac_head || q{} } @plugins;
65 return join( "\n", @data );
68 =head3 get_plugins_opac_js
70 [% KohaPlugins.get_plugins_opac_js %]
72 This method collects the output of all plugins with an opac_js method
73 to output to the javascript section of at the bottom of opac pages.
77 sub get_plugins_opac_js {
79 unless C4::Context->preference('UseKohaPlugins');
81 my $p = Koha::Plugins->new();
85 my @plugins = $p->GetPlugins(
91 my @data = map { $_->opac_js || q{} } @plugins;
93 return join( "\n", @data );