fix: [taxonomies] Counts fixed

pull/4346/head
iglocska 2019-03-19 16:40:35 +01:00
parent e028c1a886
commit e8263467df
2 changed files with 17 additions and 3 deletions

View File

@ -56,8 +56,22 @@ class TaxonomiesController extends AppController
if (empty($taxonomy)) {
throw new NotFoundException('Taxonomy not found.');
}
$this->loadModel('EventTag');
$this->loadModel('AttributeTag');
foreach ($taxonomy['entries'] as $key => $value) {
$taxonomy['entries'][$key]['events'] = empty($value['existing_tag']) ? 0 : count($value['existing_tag']['EventTag']);
$count = 0;
if (!empty($value['existing_tag'])) {
foreach ($value['existing_tag'] as $et) {
$count = $this->EventTag->find('count', array(
'conditions' => array('EventTag.tag_id' => $et['id'])
));
$count_a = $this->AttributeTag->find('count', array(
'conditions' => array('AttributeTag.tag_id' => $et['id'])
));
}
}
$taxonomy['entries'][$key]['events'] = $count;
$taxonomy['entries'][$key]['attributes'] = $count_a;
}
$this->set('filter', $filter);
$customPagination = new CustomPaginationTool();

View File

@ -102,7 +102,7 @@
<?php
if ($item['existing_tag']) {
?>
<a href='<?php echo $baseurl."/events/index/searchtag:". h($item['existing_tag']['Tag']['id']);?>'><?php echo count($item['existing_tag']['EventTag']);?></a>
<a href='<?php echo $baseurl."/events/index/searchtag:". h($item['existing_tag']['Tag']['id']);?>'><?php echo h($item['events']);?></a>
<?php
} else {
echo __('N/A');
@ -113,7 +113,7 @@
<?php
if ($item['existing_tag']):
?>
<a href='<?php echo $baseurl."/attributes/search/tags:". h($item['existing_tag']['Tag']['id']);?>'><?php echo count($item['existing_tag']['AttributeTag']);?></a>
<a href='<?php echo $baseurl."/attributes/search/tags:". h($item['existing_tag']['Tag']['id']);?>'><?php echo h($item['attributes']);?></a>
<?php
else:
echo __('N/A');