@@ -, +, @@ http://localhost:8080/cgi-bin/koha/opac-main.pl?news_id=12 --- Koha/Template/Plugin/AdditionalContents.pm | 23 ++++ .../bootstrap/en/modules/opac-main.tt | 107 +++++++++--------- opac/opac-main.pl | 24 +--- 3 files changed, 78 insertions(+), 76 deletions(-) --- a/Koha/Template/Plugin/AdditionalContents.pm +++ a/Koha/Template/Plugin/AdditionalContents.pm @@ -55,6 +55,29 @@ sub get { } } +sub get_news_id { + my ( $self, $params ) = @_; + + my $idnew = $params->{idnew}; + my $location = ['opac_only', 'staff_and_opac']; + my $blocktitle = $params->{blocktitle}; + + my $content = Koha::AdditionalContents->search( + { + location => $location, + idnew => $idnew, + } + ); + + if ( $content->count ) { + return { + content => $content, + location => $location, + blocktitle => $blocktitle + }; + } +} + 1; =head1 NAME --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -71,7 +71,7 @@

Koha home

[% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %] - [% UNLESS news_item %] + [% UNLESS news_id %]
News @@ -87,65 +87,62 @@ [% END %] [% END %] - [% IF koha_news.count %] - - [% IF single_news_error %] - -
- This news item does not exist. -
- - [% ELSE %] + [% IF news_id %] + [% SET koha_news = AdditionalContents.get_news_id( idnew => news_id ) %] + [% ELSE %] + [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %] + [% END %] + [% IF koha_news.content.count %] +
+ [% SET show_author = Koha.Preference('NewsAuthorDisplay') == 'opac' || Koha.Preference('NewsAuthorDisplay') == 'both' %] + [% FOREACH koha_new IN koha_news.content %] +
+

+ [% IF ( news_item ) %] + [% koha_new.title | html %] + [% ELSE %] + [% koha_new.title | html %] + [% END %] +

+
[% koha_new.content | $raw %]
+
+ Published on [% koha_new.published_on | $KohaDates %] + [% IF ( show_author && koha_new.author ) %] + by [% INCLUDE 'patron-title.inc' patron=koha_new.author %] + [% END %] + [% IF ( news_item ) %] + • Show all news + [% END %] +
+
+ [% END %] -
- [% SET show_author = Koha.Preference('NewsAuthorDisplay') == 'opac' || Koha.Preference('NewsAuthorDisplay') == 'both' %] - [% FOREACH koha_new IN koha_news %] -
-

- [% IF ( news_item ) %] - [% koha_new.title | html %] + [% UNLESS news_item %] +

-
[% koha_new.content | $raw %]
-
- Published on [% koha_new.published_on | $KohaDates %] - [% IF ( show_author && koha_new.author ) %] - by [% INCLUDE 'patron-title.inc' patron=koha_new.author %] - [% END %] - [% IF ( news_item ) %] - • Show all news + RSS feed for library news [% END %] -
-
- [% END %] - - [% UNLESS news_item %] - - [% END %] -
- - [% END # /IF single_news_error %] - + [% END %] + +
+ [% END %] + + [% ELSIF news_id %] +
+ This news item does not exist. +
[% ELSE %] [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
--- a/opac/opac-main.pl +++ a/opac/opac-main.pl @@ -58,26 +58,9 @@ elsif (C4::Context->userenv and defined $input->param('branch') and length $inpu $homebranch = ""; } -my $news_id = $input->param('news_id'); -my $koha_news; -if (defined $news_id){ - $koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news - if ( $koha_news->count > 0){ - $template->param( news_item => $koha_news->next ); - } else { - $template->param( single_news_error => 1 ); - } -} else { - $koha_news = Koha::AdditionalContents->search_for_display( - { - category => 'news', - location => ['opac_only', 'staff_and_opac'], - lang => $template->lang, - library_id => $homebranch, - } - ); -} +my $news_id = $input->param('news_id'); +$template->param( news_id => $news_id ); # For dashboard my $patron = Koha::Patrons->find( $borrowernumber ); @@ -108,9 +91,8 @@ if ( $patron ) { } } +$template->param( branchcode => $homebranch ) if $homebranch; $template->param( - koha_news => $koha_news, - branchcode => $homebranch, daily_quote => Koha::Quotes->get_daily_quote(), ); --