Bugzilla – Attachment 86734 Details for
Bug 22318
Extend Koha news feature to include other content areas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22318: Example implementation: OpacNavRight system preference
Bug-22318-Example-implementation-OpacNavRight-syst.patch (text/plain), 9.97 KB, created by
Josef Moravec
on 2019-03-19 08:29:58 UTC
(
hide
)
Description:
Bug 22318: Example implementation: OpacNavRight system preference
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-03-19 08:29:58 UTC
Size:
9.97 KB
patch
obsolete
>From 2cd0004edb9dc9829d04551ec26f67353ea44919 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 14 Feb 2019 15:49:25 +0000 >Subject: [PATCH] Bug 22318: Example implementation: OpacNavRight system > preference > >This patch implements a Koha news system replacement of the OpacNavRight >system preference. The changes to koha-news.tt enable the selection of >"OpacNavRight" as a location for the content. opac-main.pl is modified >to ensure that the user's selected language is passed to the template >for use by the KohaNews plugin. > >The database update process takes the contents of Koha's OpacNavRight >system preference and adds it to the Koha news system. The OpacNavRight >system preference is then removed from the database. > >When the new entry is added to Koha news, the language is set based on >the top selected language in the "opaclanguages" preference. The entry >is added to "All libraries" without an author, title, or expiration >date. > >Note that this patch doesn't change the way OPAC news is displayed. I >think it's best to keep existing markup and code for that since it >handles details like branch selection and RSS. > >To test, apply the patch and run the database update. > > - In the staff client go to Tools -> News and confirm that there is now > an entry with the location "OpacNavRight_en" (assuming an "en" > English interface). > - Confirm that the previous contents of OpacNavRight were added > correctly. > - Go to Administration -> System preferences -> OPAC and verify that > the OpacNavRight preference has been removed. > - In the OPAC, confirm that the correct content is displayed in the > region previously defined in the OpacNavRight system preference. > - Test that the language and library-specific nature of news items is > reflected in the behavior of this content area: > - Define different text based on language and location. Confirm that > switching translations and logging in to the OPAC both trigger the > correct display of different content. > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > .../bug_22313-move-opacnavright-to-news.perl | 18 +++++++++++++++ > installer/data/mysql/sysprefs.sql | 1 - > .../prog/en/modules/admin/preferences/opac.pref | 5 ----- > .../prog/en/modules/tools/koha-news.tt | 26 ++++++++++++++++------ > .../opac-tmpl/bootstrap/en/modules/opac-main.tt | 7 ++---- > opac/opac-main.pl | 1 + > 6 files changed, 40 insertions(+), 18 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_22313-move-opacnavright-to-news.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_22313-move-opacnavright-to-news.perl b/installer/data/mysql/atomicupdate/bug_22313-move-opacnavright-to-news.perl >new file mode 100644 >index 0000000000..bce5c64ff3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_22313-move-opacnavright-to-news.perl >@@ -0,0 +1,18 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ my $opaclang = C4::Context->preference("opaclanguages"); >+ my @langs; >+ push @langs, split ( '\,', $opaclang ); >+ # Get any existing value from the OpacNavRight system preference >+ my ($OpacNavRight) = $dbh->selectrow_array( q| >+ SELECT value FROM systempreferences WHERE variable='OpacNavRight'; >+ |); >+ if( $OpacNavRight ){ >+ # If there is a value in the OpacNavRight preference, insert it into opac_news >+ $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, 'OpacNavRight_$langs[0]', '', '$OpacNavRight')"); >+ } >+ # Remove the OpacNavRight system preference >+ $dbh->do("DELETE FROM systempreferences WHERE variable='OpacNavRight'"); >+ SetVersion ($DBversion); >+ print "Upgrade to $DBversion done (Bug 22318: Move contents of OpacNavRight preference to Koha news system)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index ca5256dc00..712c52c144 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -387,7 +387,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OPACMySummaryNote','','','Note to display on the patron summary page. This note only appears if the patron is connected.','Free'), > ('OpacNav','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'), > ('OpacNavBottom','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'), >-('OpacNavRight','','70|10','Show the following HTML in the right hand column of the main page under the main login form','Textarea'), > ('OpacNewsLibrarySelect','0','','Show selector for branches on OPAC news page','YesNo'), > ('OPACNoResultsFound','','70|10','Display this HTML when no results are found for a search in the OPAC','Textarea'), > ('OPACNumbersPreferPhrase','0',NULL,'Control the use of phr operator in callnumber and standard number OPAC searches','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 da1d86540c..e1c9bc336e 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 >@@ -224,11 +224,6 @@ OPAC: > type: htmlarea > class: code > - >- - "Show the following HTML in the right hand column of the main page under the main login form:" >- - pref: OpacNavRight >- type: htmlarea >- class: code >- - > - "Show the following HTML on the left hand column of the main page and patron account on the OPAC, after OpacNav, and before patron account links if available:" > - pref: OpacNavBottom > type: htmlarea >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >index f2c34a8b7d..3096ece9bd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >@@ -39,8 +39,10 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> > [% END %] > > [% IF ( add_form ) %] >- [% IF ( op == 'add' ) %][% default_lang = lang | html %] >- [% ELSE %][% default_lang = new_detail.lang | html %] >+ [% IF ( op == 'add' ) %] >+ [% default_lang = lang %] >+ [% ELSE %] >+ [% default_lang = new_detail.lang %] > [% END %] > <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" > > <input type="hidden" name="op" value="[% op | html %]" /> >@@ -66,11 +68,21 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> > <option value="slip" >Slip</option> > [% END %] > [% FOREACH lang_lis IN lang_list %] >- [% IF ( lang_lis.language == default_lang ) %] >- <option value="[% lang_lis.language | html %]" selected="selected">OPAC ([% lang_lis.language | html %])</option> >- [% ELSE %] >- <option value="[% lang_lis.language | html %]" >OPAC ([% lang_lis.language | html %])</option> >- [% END %] >+ <optgroup label="[% lang_lis.language | html %]"> >+ [% FOREACH location IN [ '', 'OpacNavRight' ] %] >+ [% IF ( location == '' ) %] >+ [% SET location_lang = lang_lis.language %] >+ [% SET location = "OPAC news" %] >+ [% ELSE %] >+ [% SET location_lang = location _ "_" _ lang_lis.language %] >+ [% END %] >+ [% IF ( location_lang == default_lang ) %] >+ <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option> >+ [% ELSE %] >+ <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option> >+ [% END %] >+ [% END %] >+ </optgroup> > [% END %] > </select> > </li> >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 82b02409e1..8947e27512 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -3,6 +3,7 @@ > [% USE KohaDates %] > [% USE Branches %] > [% USE Price %] >+[% USE KohaNews %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -191,11 +192,7 @@ > [% END %] > [% END # /loggedinusername %] > [% END # /opacuserlogin %] >- [% IF ( OpacNavRight ) %] >- <div id="opacnavright"> >- [% OpacNavRight | $raw %] >- </div> >- [% END # /OpacNavRight %] >+ [% PROCESS koha_news_block news => KohaNews.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %] > </div> <!-- / .span3 --> > [% END # /opacuserlogin || OpacNavRight %] > >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 965618c5d3..4af6f1a818 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -104,6 +104,7 @@ if ( $patron ) { > > $template->param( > koha_news => @all_koha_news, >+ news_lang => $news_lang, > branchcode => $homebranch, > display_daily_quote => C4::Context->preference('QuoteOfTheDay'), > daily_quote => $quote, >-- >2.11.0
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 22318
:
85132
|
85133
|
86728
|
86730
|
86731
|
86733
|
86734
|
86743
|
86771
|
87490
|
87491
|
87492
|
87493