diff --git a/src/SitemapHelper.php b/src/SitemapHelper.php index 5f9221f..d04d21e 100644 --- a/src/SitemapHelper.php +++ b/src/SitemapHelper.php @@ -104,7 +104,7 @@ class SitemapHelper { $last_depth = -1; - $output .= !empty($description) && $config->get('show_description') ? '
' . Xss::filterAdmin($description) . "
\n" : ''; + $description = !empty($description) && $config->get('show_description') ? '
' . Xss::filterAdmin($description) . "
\n" : ''; $depth = $config->get('vocabulary_depth'); if ($depth <= -1) { @@ -194,14 +194,18 @@ class SitemapHelper { $attributes->addClass('sitemap-box-terms', 'sitemap-box-terms-' . $vid); - $sitemap_box = array( - 'title' => $title, - 'content' => array('#markup' => $output), - 'attributes' => $attributes, - 'options' => $options, - ); + // Only provide content where terms can be listed + if (!empty($output)) { - return $sitemap_box; + $sitemap_box = [ + 'title' => $title, + 'content' => ['#markup' => $description . $output], + 'attributes' => $attributes, + 'options' => $options, + ]; + + return $sitemap_box; + } } } diff --git a/templates/sitemap.html.twig b/templates/sitemap.html.twig index fad7379..9aa592a 100644 --- a/templates/sitemap.html.twig +++ b/templates/sitemap.html.twig @@ -32,6 +32,7 @@ {% if sitemap_items %} {% for item in sitemap_items %} + {% if item.content is not empty %} {% if item.options.show_titles %}

{{ item.title }}

@@ -40,6 +41,7 @@ {{ item.content }} + {% endif %} {% endfor %} {% endif %}