From 4d80bc6f79b08582f6029787e6711c6f70557ba5 Mon Sep 17 00:00:00 2001
From: David Cook <dcook@prosentient.com.au>
Date: Thu, 27 Jun 2013 16:02:08 +1000
Subject: [PATCH] Bug 9801 - location facet shows even if no locations

Currently, the headings for facets (such as location) are showing even
if there are no actual values/links for that facet type.

This patch simply checks if the facet array contains any facets before
printing the heading and HTML for each facet value/link.

Test Plan:

Before applying:

0) If you want to check the location facet (which is easiest),
enable singlebranch  mode in the globals system preferences.

1) Do a search for records/items that you have no shelving location
specified (or simply remove the shelving location for a small range
of records that you can find in a search query).

2) Note that "Location" appears amongst the facets even though there
are no values/links present. (If you look at the HTML source, you'll
see some empty HTML tags have been printed out.)

Apply patch.

3) Flush your cache and refresh your page.
4) You should no longer see a "Location" facet (or those empty HTML
tags) on the facet sidebar.
---
 .../intranet-tmpl/prog/en/includes/facets.inc      |    2 ++
 .../opac-tmpl/prog/en/includes/opac-facets.inc     |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc
index fd2302a..8853ec7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc
@@ -8,6 +8,7 @@
 	</li>
 
 	[% FOREACH facets_loo IN facets_loop %]
+[% IF facets_loo.facets.size > 0 %]
 	<li id="[% facets_loo.type_id %]">
 [% facets_loo.type_label %]
 [% IF ( facets_loo.type_label_Authors ) %]Authors[% END %]
@@ -24,6 +25,7 @@
 [% END %]
 </ul></li>
 [% END %]
+[% END %]
 </ul>
 </div>
 [% END %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc
index fbb7c55..5486b0c 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc
@@ -8,6 +8,7 @@
 	</li>
 	
 [% FOREACH facets_loo IN facets_loop %]
+[% IF facets_loo.facets.size > 0 %]
 <li id="[% facets_loo.type_id %]">
 [% IF ( facets_loo.type_label_Authors ) %]Authors[% END %]
 [% IF ( facets_loo.type_label_Titles ) %]Titles[% END %]
@@ -25,6 +26,7 @@
 [% END %]
 </ul></li>
 [% END %]
+[% END %]
 </ul>
 </div>
 [% IF ( OPACResultsSidebar ) %]
-- 
1.7.7.4