Browse Source

Bug 13388: Add library pages to the OPAC

This patch adds a script and a template for showing library information
pages in the OPAC. A "libraries" page lists all the libraries in the
system, linking to individual pages for each library showing more
information..

If there is only one library in the system the page shows all of that
library's information.

To test, apply the patch and rebuild the OPAC CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

 - Go to /cgi-bin/koha/opac-library.pl in the OPAC.
 - Verify that all the correct information is displayed for the
   libraries in your system.
 - Verify that page title and breadcrumbs look correct.
 - Click to view details for a library.
   - The details page should show the full contents of
     branches.opac_info
   - A menu should show links to other libraries' detail pages.

EDIT: This revised patch adds a "Libraries" link to the links under the
search bar; Corrects encoding in the breadcrumb link; Makes the page
title more specific when viewing an individual library.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Owen Leonard 3 years ago
committed by Martin Renvoize
parent
commit
308d67950e
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 22
      koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss
  2. 1
      koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
  3. 149
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt
  4. 52
      opac/opac-library.pl

22
koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss

@ -1649,6 +1649,28 @@ div {
}
/* nav */
nav {
&.libraries {
li {
list-style-type: none;
padding: .3em .5em;
a {
display: block;
}
}
i.fa {
color: #7cbc0f;
}
.fa-li {
top: unset;
}
}
}
.nav_pages {
border-top: 1px solid #DDD;
padding: .6em;

1
koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc

@ -313,6 +313,7 @@
<li><a href="/cgi-bin/koha/opac-suggestions.pl?suggested_by_anyone=1">Purchase suggestions</a></li>
[% END %]
[% END %]
<li><a href="/cgi-bin/koha/opac-library.pl">Libraries</a></li>
[% Koha.Preference('OpacMoreSearches') | $raw %]
</ul>
</div> <!-- /#moresearches -->

149
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt

@ -0,0 +1,149 @@
[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>
[% IF ( LibraryNameTitle ) %]
[% LibraryNameTitle | html %]
[% ELSE %]
Koha online
[% END %] catalog &rsaquo; Libraries
[% IF ( library ) %]
&rsaquo; [% library.branchname | html %]
[% END %]
</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-library' bodyclass='scrollto' %]
[% INCLUDE 'masthead.inc' %]
[% BLOCK library_description %]
<div property="description">
[% library.opac_info | $raw %]
</div>
[% END %]
[% BLOCK library_info %]
<div property="address" typeof="PostalAddress">
<p>
<span property="streetAddress">
[% IF ( library.branchaddress1 ) %]
[% library.branchaddress1 | html %]
[% END %]
[% IF ( library.branchaddress2 ) %]
<br />[% library.branchaddress2 | html %]
[% END %]
[% IF ( library.branchaddress3 ) %]
<br />[% library.branchaddress3 | html %]
[% END %]
</span><br>
[% IF ( library.branchcity ) %]
<span property="addressLocality">[% library.branchcity | html %]</span>
[% END %]
[% IF ( library.branchstate ) %]
<span property="addressRegion">[% library.branchstate | html %]</span>
[% END %]
[% IF ( library.branchzip ) %]
<span property="postalCode">[% library.branchzip | html %]</span>
[% END %]
[% IF ( library.branchcountry ) %]
<br /><span property="addressCountry">[% library.branchcountry | html %]</span>
[% END %]
[% IF ( library.branchphone ) %]
<p>Phone: <a href="tel:[% library.branchphone | url %]" property="telephone">[% library.branchphone | html %]</a></p>
[% END %]
[% IF ( library.branchfax ) %]
<p>Fax: <span property="faxNumber">[% library.branchfax | html %]</span></p>
[% END %]
[% IF ( library.branchemail ) %]
<p>Email: <a href="mailto:[% library.branchemail | url %]" property="email">[% library.branchemail | html %]</a></p>
[% END %]
[% IF ( library.branchurl ) %]
<p><a href="[% library.branchurl | url %]" property="url">[% library.branchurl | html %]</a></p>
[% END %]
</p>
</div> <!-- /div property=address -->
[% END %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-library.pl">Libraries</a>
[% IF ( library ) %]
<span class="divider">&rsaquo;</span></li>
<li><a href="#">[% library.branchname | html %]</a></li>
[% ELSE %]
</li>
[% END %]
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
[% IF ( library ) %]
<div id="library_info" class="maincontent" vocab="http://schema.org/" typeof="Library">
<h3 property="name">[% library.branchname | html %]</h3>
<div class="row-fluid">
<div class="span8">
[% PROCESS library_info %]
[% IF ( library.opac_info ) %]
<hr />
[% PROCESS library_description %]
[% END %]
</div>
<div class="span4">
[% IF ( libraries.count > 1 ) %]
<nav class="libraries">
<ul class="fa-ul">
[% FOREACH library IN libraries %]
[% IF ( branchcode == library.branchcode ) %]
<li class="current">
<a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">
<i class="fa fa-li fa-map-pin" aria-hidden="true"></i> [% library.branchname | html %]
</a>
</li>
[% ELSE %]
<li>
<a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">
<i class="fa fa-li" aria-hidden="true"></i> [% library.branchname | html %]
</a>
</li>
[% END %]
[% END %]
</ul>
</nav>
[% END %]
</div>
</div>
</div> <!-- /#library_info -->
[% ELSE %]
<h2>Libraries</h2>
[% FOREACH library IN libraries %]
<h3 property="name">
[% IF ( libraries.count > 1 ) %]
<a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">[% library.branchname | html %]</a>
[% ELSE %]
[% library.branchname | html %]
[% END %]
</h3>
[% PROCESS library_info %]
<hr>
[% IF ( libraries.count == 1 ) %]
[% PROCESS library_description %]
[% END %]
[% END %]
[% END %]
</div> <!-- /.row-fluid -->
</div> <!-- /.container-fluid -->
</div> <!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %][% END %]

52
opac/opac-library.pl

@ -0,0 +1,52 @@
#!/usr/bin/perl
# Copyright 2020 Athens County Public Libraries
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
use Koha::Libraries;
my $query = CGI->new();
my $branchcode = $query->param('branchcode');
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-library.tt",
query => $query,
type => "opac",
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
}
);
if( $branchcode ){
my $library = Koha::Libraries->find( $branchcode );
$template->param( library => $library );
}
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] }, );
$template->param(
libraries => $libraries,
branchcode => $branchcode,
);
output_html_with_http_headers $query, $cookie, $template->output;
Loading…
Cancel
Save