Task: in category menu show count of item in each category, like
- Category_one (38)
- Category_two (14)
- Etc ...
I have try count by $demand but did'nt work
<?php
namespace HIT\huskytheme\ViewHelpers\News;
class CountCategoriesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
* @var \GeorgRinger\News\Domain\Repository\NewsRepository
* @inject
*/
protected $newsRepository = null;
/**
*
* @param string $category
* @return string
*/
public function render($category) {
$demand = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand');
//$demand->setDateField('datetime');
$demand->setStoragePage(10, true);
// for example by id = 2
$demand->setCategories(2);
$demand->setCategoryConjunction('and');
$demand->setIncludeSubCategories('1');
//$demand->setArchiveRestriction($settings['archiveRestriction']);
$statistics = $this->newsRepository->countByCategories($demand);
\TYPO3\CMS\Core\Utility\DebugUtility::debug($statistics);
return $this->newsRepository->countByCategories($demand);
}
}
But get just 0, if call
{namespace s=HIT\huskytheme\ViewHelpers}
{s:news.countCategories(category: 2)}