Skip to content

Commit

Permalink
Merge pull request #1795 from bolt/bugfix/taxonomy-empty
Browse files Browse the repository at this point in the history
Include taxonomy types if no taxonomies set
  • Loading branch information
bobdenotter authored Sep 1, 2020
2 parents 81a4500 + 90ac359 commit eb4ed4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions public/theme/skeleton/partials/_sub_taxonomylinks.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% for type, taxonomies in record|taxonomies %}
<em>
{% if taxonomies|length < 2 %}
{% if taxonomies|length == 1 %}
{{ config.get('taxonomies')[type].singular_name }}:
{% else %}
{% elseif taxonomies|length > 1 %}
{{ config.get('taxonomies')[type].name }}:
{% endif %}
</em>
Expand Down
9 changes: 9 additions & 0 deletions src/Twig/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,15 @@ private function generateLink(string $route, array $params, $canonical = false):
public function getTaxonomies(Content $content): Collection
{
$taxonomies = [];

$definition = $content->getDefinition();

if ($definition && is_iterable($definition->get('taxonomy'))) {
foreach ($definition->get('taxonomy') as $taxonomy) {
$taxonomies[$taxonomy] = [];
}
}

foreach ($content->getTaxonomies() as $taxonomy) {
$taxonomies[$taxonomy->getType()][$taxonomy->getSlug()] = $taxonomy;
}
Expand Down

0 comments on commit eb4ed4c

Please sign in to comment.