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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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 );
96 =head3 get_plugins_intranet_head
98 [% KohaPlugins.get_plugins_intranet_head %]
100 This method collects the output of all plugins with an intranet_head method
101 to output to the head section of intranet pages.
105 sub get_plugins_intranet_head {
107 unless C4::Context->preference('UseKohaPlugins');
109 my $p = Koha::Plugins->new();
111 return q{} unless $p;
113 my @plugins = $p->GetPlugins(
115 method => 'intranet_head',
119 my @data = map { $_->intranet_head || q{} } @plugins;
121 return join( "\n", @data );
124 =head3 get_plugins_intranet_js
126 [% KohaPlugins.get_plugins_intranet_js %]
128 This method collects the output of all plugins with an intranet_js method
129 to output to the javascript section of at the bottom of intranet pages.
133 sub get_plugins_intranet_js {
135 unless C4::Context->preference('UseKohaPlugins');
137 my $p = Koha::Plugins->new();
139 return q{} unless $p;
141 my @plugins = $p->GetPlugins(
143 method => 'intranet_js',
147 my @data = map { $_->intranet_js || q{} } @plugins;
149 return join( "\n", @data );