From 5e2982d180d0f62a0ce2ec7746aeded6db3fa3db 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 verify the bug, remove your opacheader news entry and view source on any page in the OPAC. You should find some empty markup right after ' '
To test the fix, apply the patch and reload the OPAC page. The empty divs should be gone. 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