Bug 23050: Plugin hook to add tabs in intranet biblio details page
authorJulian Maurice <julian.maurice@biblibre.com>
Wed, 5 Jun 2019 14:26:34 +0000 (16:26 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 5 Nov 2019 08:13:35 +0000 (08:13 +0000)
Test Plan:
1) Enable plugins
2) Download and install the latest version of this plugin
https://git.biblibre.com/biblibre/koha-plugin-intranet-detail-hook
3) Browse to catalogue/detail.pl for a record
4) Note you see two new tabs with content

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

index 303d709..1103d2e 100755 (executable)
@@ -69,8 +69,23 @@ if ( C4::Context->preference('UseKohaPlugins') &&
     my @plugins = Koha::Plugins->new()->GetPlugins({
         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
     });
+
+    my @tab_plugins = Koha::Plugins->new()->GetPlugins({
+        method => 'intranet_catalog_biblio_tab',
+    });
+    my @tabs;
+    foreach my $tab_plugin (@tab_plugins) {
+        my @biblio_tabs = $tab_plugin->intranet_catalog_biblio_tab();
+        foreach my $tab (@biblio_tabs) {
+            $tab->{id} = $tab->{title};
+            $tab->{id} =~ s/[^\w]+/-/g;
+            push @tabs, $tab,
+        }
+    }
+
     $template->param(
-        plugins => \@plugins
+        plugins => \@plugins,
+        tabs => \@tabs,
     );
 }
 
index f3bb3a1..19b54a0 100644 (file)
 [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
     <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
 [% END %]
+[% FOREACH tab IN tabs %]
+    <li><a href="#[% tab.id %]">[% tab.title %]</a></li>
+[% END %]
 </ul>
 
 [% items_table_block_iter = 0 %]
     </div>
 [% END %]
 
+[% FOREACH tab IN tabs %]
+    <div id="[% tab.id | html %]">
+        [% tab.content | $raw %]
+    </div>
+[% END %]
+
 </div><!-- /bibliodetails -->
 
 <div id="export" style="margin-top: 1em;">