Skip to content

Commit

Permalink
Merge pull request #582 from bolt/hotfix/taxo-controller
Browse files Browse the repository at this point in the history
Fix taxonomy controller
  • Loading branch information
bobdenotter authored Aug 11, 2019
2 parents fd692b8 + e70ddf0 commit 9ecf73b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
17 changes: 3 additions & 14 deletions public/theme/skeleton/listing.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@
are on this page. It can be used for overview pages like 'all entries', or
'all records tagged with kittens'. #}

{# If used for listing a taxonomy, we add a heading.: #}
{% if taxonomy|default %}
{# If used for listing a taxonomy, we add a heading #}
{% if taxonomy is defined %}
<h1>
{{ __('general.phrase.overview-for') }}
{% if taxonomy.options[slug] is defined %}
{{ taxonomy.options[slug] }}
{% else %}
{{ slug }}
{% endif %}
{{ __('general.phrase.overview-for', {'%slug%': taxonomy.options[slug]|default(slug) }) }}
</h1>
{# Taxonomies are fetched unordered by design except if 'has_sortorder'
is set to true. This way we keep 'grouping' intact in the listing. #}
{% if not taxonomy.has_sortorder %}
{# If we specified an order in config.yml, sort them here, accordingly: #}
{% set records = records|order(config.get('general/listing_sort')) %}
{% endif %}
{% endif %}

{% for record in records %}
Expand Down
10 changes: 9 additions & 1 deletion src/Controller/Frontend/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ public function listing(ContentRepository $contentRepository, Request $request,
$page = (int) $request->query->get('page', 1);
$amountPerPage = $this->config->get('general/listing_records');

$taxonomy = $this->config->get('taxonomies/'. $taxonomyslug);

/** @var Content[] $records */
$records = $contentRepository->findForTaxonomy($page, $taxonomyslug, $slug, $amountPerPage);

$templates = $this->templateChooser->forTaxonomy($taxonomyslug);

return $this->renderTemplate($templates, ['records' => $records]);
$twigVars = [
'records' => $records,
'taxonomy' => $taxonomy,
'slug' => $slug,
];

return $this->renderTemplate($templates, $twigVars);
}
}
18 changes: 18 additions & 0 deletions translations/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1821,5 +1821,23 @@
<target>Predominant colors in image</target>
</segment>
</unit>
<unit id="8RPjZ5w" name="general.phrase.overview-for">
<segment>
<source>general.phrase.overview-for</source>
<target>Overview for '%slug%'</target>
</segment>
</unit>
<unit id="6mze9DI" name="general.phrase.related-content">
<segment>
<source>general.phrase.related-content</source>
<target>Related content</target>
</segment>
</unit>
<unit id="odDw0du" name="action.search">
<segment>
<source>action.search</source>
<target>Search</target>
</segment>
</unit>
</file>
</xliff>

0 comments on commit 9ecf73b

Please sign in to comment.