From bb0151d65439b4ed3fb4ca1b8dca9a1f49cd5989 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 27 Jun 2024 19:15:11 +0000 Subject: [PATCH] Bug 36742: Do not show library selection options if there is one or fewer public libraries If a system has only one library or only one library which is public we don't need to show library-selection menus. It doesn't make sense to show a dropdown with only one choice. This patch updates instances of Branches.all to add a "public => 1" parameter. To test, apply the patch and start with a set of multiple public libraries in your system (where public means the entry in Administration -> Libraries for that library has the "Public" option set to "Yes"). Log in to the OPAC test these pages, in each case confirming that the the library dropdown appears correctly. - OPAC home page (with OpacAddMastheadLibraryPulldown enabled) - OPAC news section (with existing news items and OpacNewsLibrarySelect enabled) - Advanced search (Location and availability section) - The "Most popular" page (with OpacTopissue enabled) - The suggestion entry form (with suggestion enabled) - The article request entry form (with ArticleRequests enabled and circulation rules configured to allow requests) Test again with only one library or only one public library. Test again with no public libraries. Sponsored-by: Athens County Public Libraries Signed-off-by: Jake Deery --- .../bootstrap/en/includes/masthead.inc | 10 ++--- .../bootstrap/en/includes/opac-topissues.inc | 15 ++++--- .../bootstrap/en/modules/opac-advsearch.tt | 44 +++++++++++-------- .../bootstrap/en/modules/opac-main.tt | 5 ++- .../en/modules/opac-request-article.tt | 25 ++++++----- .../bootstrap/en/modules/opac-suggestions.tt | 7 +-- 6 files changed, 61 insertions(+), 45 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 21780d429b0..b0a93194c05 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -16,6 +16,7 @@ [% SET OpacMoreSearches = AdditionalContents.get( location => "OpacMoreSearches", lang => lang, library => branchcode || default_branch ) %] [% SET CookieConsentBar = AdditionalContents.get( location => "CookieConsentBar", lang => lang, library => branchcode || default_branch ) %] [% SET CookieConsentPopup = AdditionalContents.get( location => "CookieConsentPopup", lang => lang, library => branchcode || default_branch ) %] +[% SET AllPublicBranches = Branches.all( search_params => { public => 1 }, selected => opac_name ) %]
@@ -251,15 +252,14 @@ [% END # /ms_value %]
- [% IF ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 ) %] + [% IF ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 && AllPublicBranches.size > 1 ) %]
- [% IF Branches.all.size > 1 %] -
  • -
  • + [% IF AllPublicBranches.size > 1 %] +
  • + + +
  • [% END %] [% OpacAdvancedSearchTypes = Koha.Preference('OpacAdvancedSearchTypes').split('\|') %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 21d4d1b0251..3b7792ba21a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -9,6 +9,8 @@ [% INCLUDE 'bodytag.inc' bodyid='advsearch' bodyclass='scrollto' %] [% INCLUDE 'masthead.inc' %] +[% SET AllPublicBranches = Branches.all( search_params => { public => 1 } ) %] +
    @@ -227,27 +229,33 @@
    - - - [% IF search_groups %] -

    OR

    - - + + [% FOREACH BranchesLoo IN AllPublicBranches %] + [% IF BranchesLoo.selected %] + + [% ELSE %] + [% END %] + [% END %] + [% IF search_groups %] +

    OR

    + + + [% END %] [% END %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index a8fdf2c43b4..f612bec1ec0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -12,6 +12,7 @@ [% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => lang, library => logged_in_user.branchcode || default_branch ) %] [% SET OpacMainUserBlock = AdditionalContents.get( location => "OpacMainUserBlock", lang => lang, library => logged_in_user.branchcode || default_branch ) %] [% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode || default_branch ) %] +[% SET AllPublicBranches = Branches.all( search_params => { public => 1 }, selected => branchcode ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog @@ -64,7 +65,7 @@

    Koha home

    - [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %] + [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) && AllPublicBranches.size > 1 %] [% UNLESS news_id %] News @@ -75,7 +76,7 @@ [% ELSE %] [% END %] - [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %] + [% PROCESS options_for_libraries libraries => AllPublicBranches %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt index b646fa577d4..41f9beba6ed 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt @@ -16,6 +16,7 @@ [% INCLUDE 'masthead.inc' %] [% SET disclaimer = AdditionalContents.get( location => "ArticleRequestsDisclaimerText", lang => lang, library => logged_in_user.branchcode || default_branch ) %] +[% SET AllPublicBranches = Branches.all( search_params => { public => 1 } ) %]
    [% WRAPPER breadcrumbs %] @@ -163,18 +164,20 @@ -
  • - - + [% FOREACH b IN AllPublicBranches %] + [% IF b.branchcode == Branches.GetLoggedInBranchcode %] + + [% ELSE %] + + [% END %] [% END %] - [% END %] - -
  • + + + [% END %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 7c5feb8d848..ade5b49e814 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -8,6 +8,7 @@ [% SET opacsuggestion = AdditionalContents.get( location => "OpacSuggestioninstructions", lang => lang, library => logged_in_user.branchcode || default_branch ) %] [% 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 ) %] +[% SET AllPublicBranches = Branches.all( search_params => { public => 1 }, selected => logged_in_user.branchcode ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( op_add_form ) %]Enter a new purchase suggestion[% END %] [% IF ( op_else ) %]Purchase suggestions[% END %] › @@ -219,19 +220,19 @@ [% END %] </li> [% END %] - [% UNLESS ( branchcode_hidden )%] + [% UNLESS ( branchcode_hidden || AllPublicBranches.size < 2 )%] <li> [% IF ( branchcode_required ) %] <label for="branch" class="required">Library:</label> <select name="branchcode" id="branch" required="required"> <option value=""></option> - [% PROCESS options_for_libraries libraries => Branches.all( selected => logged_in_user.branchcode ) %] + [% PROCESS options_for_libraries libraries => AllPublicBranches %] </select> <div class="required_label required">Required</div> [% ELSE %] <label for="branch">Library:</label> <select name="branchcode" id="branch"> - [% PROCESS options_for_libraries libraries => Branches.all( selected => logged_in_user.branchcode ) %] + [% PROCESS options_for_libraries libraries => AllPublicBranches %] </select> [% END %] </li> -- 2.39.3 (Apple Git-146)