From e8282aaf9caa772637e0bc1af3cf42d57b590520 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 27 Feb 2020 01:31:37 +0000 Subject: [PATCH] Bug 24745: OPAC news block plugin should evaluate as false if there are no items This patch changes the way news is returned from GetNewsToDisplay in KohaNews.pm so that the template variable will evaluate as false instead of simply being an empty data structure. To reproduce the bug, remove your opacheader news entry and add this to OpacUserCSS: Go to the OPAC and you should see an empty blue-bordered box at the top of the page. To test the fix, apply the patch and reload the OPAC page. The box should disappear. Add content to the opacheader news item and confirm that it displays correctly. --- Koha/Template/Plugin/KohaNews.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Koha/Template/Plugin/KohaNews.pm b/Koha/Template/Plugin/KohaNews.pm index bd56f63e2df..713d07301a0 100644 --- a/Koha/Template/Plugin/KohaNews.pm +++ b/Koha/Template/Plugin/KohaNews.pm @@ -45,11 +45,15 @@ sub get { my $content = &GetNewsToDisplay( $news_lang, $library ); - return { - content => $content, - location => $display_location, - blocktitle => $blocktitle - }; + if( @$content ){ + return { + content => $content, + location => $display_location, + blocktitle => $blocktitle + }; + } else { + return 0; + } } 1; -- 2.11.0