+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,
+ }
+ );
+}