From cf787b3d0818874c76380c8981cade8c74b92520 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 7 Apr 2022 11:22:28 +0000 Subject: [PATCH] Bug 30289: Demonstrate using a WRAPPER with opac-library.pl This patch replaces template boiler plate by using the Template::Toolkit directive WRAPPER. Test plan: 1. Go to http://localhost:8080/cgi-bin/koha/opac-library.pl 2. Outputs a list of libraries 3. Go to http://localhost:8080/cgi-bin/koha/opac-library.pl?branchcode=CPL 4. Outputs details for Centerville library only FIXME: I still need to improve the handling of the element and the breadcrumbs, but those shouldn't be too challenging. --- .../bootstrap/en/includes/wrapper_page.inc | 79 +++++++ .../bootstrap/en/modules/opac-library.tt | 223 ++++++++---------- 2 files changed, 180 insertions(+), 122 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/wrapper_page.inc diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/wrapper_page.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/wrapper_page.inc new file mode 100644 index 0000000000..39fa9c801a --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/wrapper_page.inc @@ -0,0 +1,79 @@ +[%# Modelled after opac-main.tt %] +[% IF ( ! bodyid ); bodyid='default'; END; %] +[% IF ( ! columns ); columns="one"; END; %] +[% IF ( ! include_navigation ); include_navigation=false; END; %] +[% USE raw %] +[% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] +[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %] +[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %] +[% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => lang, library => branchcode ) %] +[% SET OpacMainUserBlock = AdditionalContents.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %] +[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] +[% INCLUDE 'doc-head-open.inc' %] +<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalogue +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + +[% INCLUDE 'bodytag.inc' bodyid=bodyid bodyclass='scrollto'%] +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+ [% IF + ( columns == "three_rightside_leftside" ) || + ( columns == "two_leftside" ) + %] +
+ [% IF ( include_navigation ) %] + + [% END %] +
+ [% END %] + + [% IF ( columns == "three_rightside_leftside" ) %] + [% # Three-column layout with right and left sidebars %] +
+ [% ELSIF ( columns == "two_rightside" ) %] + [% # Two-column layout with right sidebar %] +
+ [% ELSIF ( columns == "two_leftside" ) %] + [% # Two-column layout with left sidebar %] +
+ [% ELSE %] +
+ [% END %] + [% content %] +
+ + [% IF + ( columns == "three_rightside_leftside" ) || + ( columns == "two_rightside" ) + %] +
+ [%# FIXME: Add right sidebar content here %] +
+ [% END %] + +
+
+
+ +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %][% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt index 9566efa093..c6a3ee7e5a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt @@ -1,11 +1,6 @@ [% USE raw %] -[% USE Asset %] -[% USE Koha %] [% PROCESS 'display-library-address.inc' %] -[% USE AdditionalContents %] -[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] -[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] -[% INCLUDE 'doc-head-open.inc' %] + - [% IF ( library.branchphone ) %] -

Phone: [% library.branchphone | html %]

- [% END %] - [% IF ( library.branchfax ) %] -

Fax: [% library.branchfax | html %]

- [% END %] - [% IF ( library.branchurl ) %] -

[% library.branchurl | html %]

- [% END %] -[% END %] - -
+--> + - -
-
- [% IF ( OpacNav || OpacNavBottom ) %] -
- -
-
- [% ELSE %] -
- [% END %] - - [% IF ( library ) %] + +--> +[%# FIX population %] +[%# FIX breadcrumbs %] +[% WRAPPER wrapper_page.inc + bodyid='opac-library' + breadcrumb_label="Libraries" + columns="two_leftside" + include_navigation=1 +%] + [% IF ( library ) %] - <div id="library_info" class="maincontent" vocab="http://schema.org/" typeof="Library"> - <h1 property="name">[% library.branchname | html %]</h1> + <div id="library_info" class="maincontent" vocab="http://schema.org/" typeof="Library"> + <h1 property="name">[% library.branchname | html %]</h1> - <div class="row"> - <div class="col-lg-8"> - [% PROCESS library_info %] - [% IF ( library.opac_info ) %] - <div class="library_description"> - <hr /> - [% PROCESS library_description %] - </div> + <div class="row"> + <div class="col-lg-8"> + [% PROCESS library_info %] + [% IF ( library.opac_info ) %] + <div class="library_description"> + <hr /> + [% PROCESS library_description %] + </div> + [% END %] + </div> + <div class="col-lg-4"> + [% IF ( libraries.count > 1 ) %] + <nav class="libraries"> + <ul class="fa-ul"> + [% FOREACH library IN libraries %] + [% IF ( branchcode == library.branchcode ) %] + <li id="menu_[% library.branchcode| html %]" 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 id="menu_[% library.branchcode| html %]"> + <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 %] - </div> - <div class="col-lg-4"> - [% IF ( libraries.count > 1 ) %] - <nav class="libraries"> - <ul class="fa-ul"> - [% FOREACH library IN libraries %] - [% IF ( branchcode == library.branchcode ) %] - <li id="menu_[% library.branchcode| html %]" 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 id="menu_[% library.branchcode| html %]"> - <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 # /IF libraries.count > 1 %] - </div> <!-- /.col-lg-4 --> - </div> <!-- /.row --> - </div> <!-- /#library_info --> + </ul> + </nav> + [% END # /IF libraries.count > 1 %] + </div> <!-- /.col-lg-4 --> + </div> <!-- /.row --> + </div> <!-- /#library_info --> - [% ELSE %] - <div id="library_info" class="maincontent"> - <h1>[% IF ( singleBranchMode ) %]Library[% ELSE %]Libraries[% END %]</h1> + [% ELSE %] + <div id="library_info" class="maincontent"> + <h1>[% IF ( singleBranchMode ) %]Library[% ELSE %]Libraries[% END %]</h1> - [% FOREACH library IN libraries %] - <div class="section_library" id="section_[% library.branchcode | html %]"> - <h2 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 %] - </h2> - [% PROCESS library_info %] - </div> - [% IF ( libraries.count == 1 ) %] - <div class="library_description"> - [% PROCESS library_description %] - </div> - [% END %] + [% FOREACH library IN libraries %] + <div class="section_library" id="section_[% library.branchcode | html %]"> + <h2 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 %] - </div> <!-- /#library_info --> - [% END # /IF library %] - </div> <!-- /.col --> - </div> <!-- /.row --> - </div> <!-- /.container-fluid --> -</div> <!-- / .main --> + </h2> + [% PROCESS library_info %] + </div> + [% IF ( libraries.count == 1 ) %] + <div class="library_description"> + [% PROCESS library_description %] + </div> + [% END %] + [% END %] + </div> <!-- /#library_info --> + [% END # /IF library %] +[% END #/WRAPPER %] -[% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %][% END %] +[% BLOCK cssinclude %] + <style> + .section_library { + margin-top: 1rem; + margin-bottom: 1rem; + border: 0; + border-bottom: 1px solid rgba(0,0,0,.1); + } + </style> +[% END %] +[% BLOCK library_info %] + <div class="branchaddress" property="address" typeof="PostalAddress"> + [% PROCESS 'display-library-address' %] + </div> <!-- /div property=address --> + [% IF ( library.branchphone ) %] + <p class="branchphone">Phone: <a href="tel:[% library.branchphone | url %]" property="telephone">[% library.branchphone | html %]</a></p> + [% END %] + [% IF ( library.branchfax ) %] + <p class="branchfax">Fax: <span property="faxNumber">[% library.branchfax | html %]</span></p> + [% END %] + [% IF ( library.branchurl ) %] + <p class="branchurl"><a href="[% library.branchurl | url %]" property="url">[% library.branchurl | html %]</a></p> + [% END %] +[% END %] +[% BLOCK library_description %] + <div property="description"> + [% library.opac_info | $raw %] + </div> +[% END %] -- 2.25.1