From 47a7cb6f1afe258b87729ff478bf182a146c1f82 Mon Sep 17 00:00:00 2001 From: Oliver Isaac Date: Mon, 3 Sep 2018 13:18:19 -0500 Subject: [PATCH] Added posts to each texonomy item with attributes .type and .id --- src/Twig/TaxonomyListExtension.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Twig/TaxonomyListExtension.php b/src/Twig/TaxonomyListExtension.php index b4402ba..d92269f 100644 --- a/src/Twig/TaxonomyListExtension.php +++ b/src/Twig/TaxonomyListExtension.php @@ -70,6 +70,16 @@ public function twigTaxonomyList($name = false, $params = false) $options[$slug]['weight'] = $item['weight']; $options[$slug]['weightclass'] = $item['weightclass']; } + if (array_key_exists('posts', $item)) { + $options[$slug]['posts'] = array(); + foreach( explode( ";;;", $item['posts'] ) as $post ){ + $post_attrs = explode( ":::", $post ); + array_push( $options[$slug]['posts'], array( + 'type' => $post_attrs[0], + 'id' => $post_attrs[1], + ) ); + } + } } return $options; } @@ -119,7 +129,7 @@ protected function getFullTaxonomy($name = null, $taxonomy = null, $params = nul if (!$contenttype) { // the normal query $query = sprintf( - "SELECT COUNT(name) as count, slug, name + "SELECT COUNT(name) as count, slug, name, GROUP_CONCAT( contenttype || ':::' || content_id, ';;;' ) as posts FROM %s WHERE taxonomytype IN ('%s') GROUP BY name, slug, sortorder @@ -133,7 +143,7 @@ protected function getFullTaxonomy($name = null, $taxonomy = null, $params = nul $contenttype_table = $prefix . $contenttype; // the normal query with only published items $query = sprintf( - "SELECT COUNT(name) as count, slug, name + "SELECT COUNT(name) as count, slug, name, GROUP_CONCAT( contenttype || ':::' || content_id, ';;;' ) as posts FROM %s WHERE taxonomytype = '%s' AND contenttype = '%s'