From 2177fa1242a0a036ecd4ec3e50d54c973a75b050 Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Mon, 14 Dec 2015 22:18:18 +0100 Subject: [PATCH] Bug 14272: OPAC show single news This change makes the news shown on opac-main-pl have clickable headings which shows just that news item in isolation. This is to allow further patches that adds commentary functions. Sponsored-By: Halland County Library Test plan: * Apply this patch. * Go to OPAC main, you should see multiple news items by default. * If you do not see any, go to Staff interface and add a few. * Each nes item heading should be clickable. * When clicked only that item should be shown. * The URL should contain a new parameter named 'news_id'. * When 'news_id' is present, only a single news item should show. Updates: * Renamed URL parameter and local variables with 'news_' prefix. * Fixed Search-And-Replace error; 'news_news_id' => 'news_id' --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- opac/opac-main.pl | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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 7e51a94..af67967 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -43,7 +43,7 @@ [% SET newsdisp = ( Koha.Preference('NewsAuthorDisplay') ) %] [% FOREACH koha_new IN koha_news %]
-

[% koha_new.title %]

+

[% koha_new.title %]

[% koha_new.new %]
(published on [% koha_new.newdate %][% IF ( (newsdisp == 'opac' || newsdisp == 'both') && koha_new.borrowernumber ) %] by [% koha_new.author_title %] [% koha_new.author_firstname %] [% koha_new.author_surname %][% END %])
diff --git a/opac/opac-main.pl b/opac/opac-main.pl index b0904c5..3d32e2c 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -51,8 +51,16 @@ my $homebranch; if (C4::Context->userenv) { $homebranch = C4::Context->userenv->{'branch'}; } -my $all_koha_news = &GetNewsToDisplay($news_lang,$homebranch); -my $koha_news_count = scalar @$all_koha_news; + +my $news_id = $input->param('news_id'); +my ($all_koha_news, $koha_news_count); +if (defined $news_id && length $news_id) { + $all_koha_news = [ get_opac_new($news_id) ]; + $koha_news_count = 1; +} else { + $all_koha_news = GetNewsToDisplay($news_lang, $homebranch); + $koha_news_count = scalar @$all_koha_news; +} my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha -- 2.1.4