Bugzilla – Attachment 133074 Details for
Bug 30289
Use Template::Toolkit WRAPPER to reduce template boilerplate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30289: Demonstrate using a WRAPPER with opac-library.pl
Bug-30289-Demonstrate-using-a-WRAPPER-with-opac-li.patch (text/plain), 16.08 KB, created by
David Cook
on 2022-04-07 11:27:17 UTC
(
hide
)
Description:
Bug 30289: Demonstrate using a WRAPPER with opac-library.pl
Filename:
MIME Type:
Creator:
David Cook
Created:
2022-04-07 11:27:17 UTC
Size:
16.08 KB
patch
obsolete
>From cf787b3d0818874c76380c8981cade8c74b92520 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >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 <title> 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</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% BLOCK cssinclude %][% END %] >+</head> >+[% INCLUDE 'bodytag.inc' bodyid=bodyid bodyclass='scrollto'%] >+[% INCLUDE 'masthead.inc' %] >+ >+<div class="main"> >+ <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs"> >+ <ol class="breadcrumb"> >+ <li class="breadcrumb-item"> >+ <a href="/cgi-bin/koha/opac-main.pl">Home</a> >+ </li> >+ [% IF breadcrumb_label %] >+ <li class="breadcrumb-item active"> >+ <a href="#" aria-current="page">[% breadcrumb_label %]</a> >+ </li> >+ [% END %] >+ </ol> >+ </nav> <!-- /#breadcrumbs --> >+ >+ <div class="container-fluid"> >+ <div class="row"> >+ [% IF >+ ( columns == "three_rightside_leftside" ) || >+ ( columns == "two_leftside" ) >+ %] >+ <div class="col-12 col-lg-2 order-3 order-lg-1"> >+ [% IF ( include_navigation ) %] >+ <div id="navigation"> >+ [% INCLUDE 'navigation.inc' %] >+ </div> >+ [% END %] >+ </div> >+ [% END %] >+ >+ [% IF ( columns == "three_rightside_leftside" ) %] >+ [% # Three-column layout with right and left sidebars %] >+ <div class="col-12 col-lg-7 order-md-1 maincontent"> >+ [% ELSIF ( columns == "two_rightside" ) %] >+ [% # Two-column layout with right sidebar %] >+ <div class="col-12 col-lg-9 order-md-1 maincontent"> >+ [% ELSIF ( columns == "two_leftside" ) %] >+ [% # Two-column layout with left sidebar %] >+ <div class="col-12 col-lg-10 order-md-1 maincontent"> >+ [% ELSE %] >+ <div class="col order-md-1 maincontent"> >+ [% END %] >+ [% content %] >+ </div> >+ >+ [% IF >+ ( columns == "three_rightside_leftside" ) || >+ ( columns == "two_rightside" ) >+ %] >+ <div class="col-12 col-lg-3 order-md-2"> >+ [%# FIXME: Add right sidebar content here %] >+ </div> >+ [% END %] >+ >+ </div> <!-- /.container-fluid --> >+ </div> <!-- /.row --> >+</div> <!-- /.main --> >+ >+[% 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' %] >+<!-- > <title> > [% IF ( library ) %] > [% library.branchname | html %] › >@@ -18,44 +13,8 @@ > Koha online > [% END %] catalog > </title> >-[% INCLUDE 'doc-head-close.inc' %] >-[% BLOCK cssinclude %] >- <style> >- .section_library { >- margin-top: 1rem; >- margin-bottom: 1rem; >- border: 0; >- border-bottom: 1px solid rgba(0,0,0,.1); >- } >- </style> >-[% 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 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 %] >- >-<div class="main"> >+--> >+<!-- > <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs"> > <ol class="breadcrumb"> > <li class="breadcrumb-item"> >@@ -74,89 +33,109 @@ > </li> > [% END %] > </ol> >- </nav> <!-- /#breadcrumbs --> >- >- <div class="container-fluid"> >- <div class="row"> >- [% IF ( OpacNav || OpacNavBottom ) %] >- <div class="col-lg-2"> >- <div id="navigation"> >- [% INCLUDE 'navigation.inc' %] >- </div> >- </div> >- <div class="col-10 order-first order-md-first order-lg-2"> >- [% ELSE %] >- <div class="col order-first order-md-first order-lg-2"> >- [% END %] >- >- [% IF ( library ) %] >+ </nav> >+--> >+[%# FIX <title> 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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30289
:
131649
| 133074