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')
52 && C4::Context->config("enable_plugins");
54 my @plugins = Koha::Plugins->new()->GetPlugins(
56 method => 'opac_head',
60 my @data = map { $_->opac_head || q{} } @plugins;
62 return join( "\n", @data );
65 =head3 get_plugins_opac_js
67 [% KohaPlugins.get_plugins_opac_js %]
69 This method collects the output of all plugins with an opac_js method
70 to output to the javascript section of at the bottom of opac pages.
74 sub get_plugins_opac_js {
76 unless C4::Context->preference('UseKohaPlugins')
77 && C4::Context->config("enable_plugins");
79 my @plugins = Koha::Plugins->new()->GetPlugins(
85 my @data = map { $_->opac_js || q{} } @plugins;
87 return join( "\n", @data );