From 7376e345e05014ffd55bac65a33c65202efe2c46 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 Content-Type: text/plain; charset=utf-8 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. Signed-off-by: Bernardo Gonzalez Kriegel Divs gone, no errors. Signed-off-by: Marcel de Rooy --- 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 bd56f63e2d..713d07301a 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