From 781ef6c4c44edb94ea8fa70bfcc2fe66838ac6a8 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Sep 2023 17:21:37 +0000 Subject: [PATCH] Bug 34869: Convert OPACResultsSidebar system preference to HTML customization This patch moves the OPACResultsSidebar system preference into HTML customizations, making it possible to have language- and library-specific content. To test you should have some content in the OPACResultsSidebar system preference before applying the patch. Apply the patch and run the database update process. - Go to the OPAC and perform a catalog search. - Confirm that the content in the sidebar under the search facets, which was previously in the OPACResultsSidebar system preference, is still displayed. - In the staff client, go to Tools -> HTML customizations and verify that the content from OPACResultsSidebar is now stored there. - The HTML customization entry form should offer OPACResultsSidebar as a choice under "Display location." - Update and reinstall active translations (for instance fr-FR): - cd misc/translator/ - perl translate update fr-FR - perl translate install fr-FR - Enable the translation if necessary under Administration -> System preferences -> language. - Enable the "opaclanguagesdisplay" preference if necessary. - Edit the OPACResultsSidebar HTML customization and add unique content to the "fr-FR" tab. - Go to the OPAC and switch to your updated translation. Perform another catalog search to confirm that the content you added for your translation shows up correctly. - Go to Administration -> System preferences and confirm that the OPACResultsSidebar preference has been removed. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- ...acresultssidebar-to-additional-contents.pl | 31 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/modules/admin/preferences/opac.pref | 6 ---- .../en/modules/tools/additional-contents.tt | 2 +- .../bootstrap/en/includes/opac-facets.inc | 4 ++- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-34869-move-opacresultssidebar-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-34869-move-opacresultssidebar-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-34869-move-opacresultssidebar-to-additional-contents.pl new file mode 100755 index 0000000000..2003962bed --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-34869-move-opacresultssidebar-to-additional-contents.pl @@ -0,0 +1,31 @@ +use Modern::Perl; + +return { + bug_number => "34869", + description => "Move OPACResultsSidebar to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the OPACResultsSidebar system preference + my ($opacresultssidebar) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='OPACResultsSidebar'; + | + ); + if ($opacresultssidebar) { + + # Insert any values found from system preference into additional_contents + foreach my $lang ('default') { + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OPACResultsSidebar', 'OPACResultsSidebar', NULL, ?, ?, ?, CAST(NOW() AS date) )", + undef, "OPACResultsSidebar $lang", $opacresultssidebar, $lang + ); + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='OPACResultsSidebar'"); + say $out "Bug 34869 update done"; + } + } + } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b599a6569d..286093a8e6 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -507,7 +507,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACReportProblem', 0, NULL, 'Allow patrons to submit problem reports for OPAC pages to the library or Koha Administrator', 'YesNo'), ('OpacResetPassword','0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo'), ('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'), -('OPACResultsSidebar','','70|10','Define HTML to be included on the search results page, underneath the facets sidebar','Textarea'), ('OPACResultsUnavailableGroupingBy','branch','branch|substatus|branchonly','Group OPAC XSLT results by branch and substatus, or substatus only, or branch only','Choice'), ('OPACSearchForTitleIn','Other Libraries (WorldCat)\nOther Databases (Google Scholar)\nOnline Stores (Bookfinder.com)\nOpen Library (openlibrary.org)','70|10','Enter the HTML that will appear in the \'Search for this title in\' box on the detail page in the OPAC. Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable \'More Searches\' menu.','Textarea'), ('OpacSeparateHoldings','0',NULL,'Separate current branch holdings from other holdings (OPAC)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index e61ef57c42..f6dc65cb3c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -245,12 +245,6 @@ OPAC: type: textarea syntax: text/html class: code - - - - "Include the following HTML under the facets in OPAC search results:" - - pref: OPACResultsSidebar - type: textarea - syntax: text/html - class: code - - pref: OpacAddMastheadLibraryPulldown choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index ab5fbad1a4..d8166c4999 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -524,7 +524,7 @@ [% END %] [% END %] [% ELSE %] - [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] + [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] [% FOREACH l IN opac_available_options.sort %] [% IF l == location %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc index e66a89b45c..c1ac9a57ef 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc @@ -2,6 +2,8 @@ [% USE AuthorisedValues %] [% USE Languages %] [% PROCESS 'i18n.inc' %] +[% USE AdditionalContents %] +[% SET OPACResultsSidebar = AdditionalContents.get( location => "OPACResultsSidebar", lang => lang, library => branchcode || default_branch ) %] [% IF ( opacfacets && facets_loop && total ) %]

Refine your search

@@ -122,7 +124,7 @@ [% IF ( OPACResultsSidebar ) %]
- [% OPACResultsSidebar | $raw %] + [% PROCESS koha_news_block news => OPACResultsSidebar %]
[% END %] [% END # / IF opacfacets && facets_loop %] -- 2.39.5