I’m trying to show related news inside one news object – I’ve gotten probably halfway there, but I’m stuck where I need to remove duplicates.
In the docs, I found that I could use a custom hook for this – so I added the fol
$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Domain/Repository/AbstractDemandedRepository.php']['findDemanded'][$_EXTKEY] = \REDACTED\NewsExtended\Hooks\Repository::class . '->modify';
And in the Repository.php:
namespace REDACTED\NewsExtended\Hooks;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use \GeorgRinger\News\Domain\Repository\NewsRepository;
class Repository
{
public function modify(array $params, NewsRepository $newsRepository)
{
$this->updateConstraints($params['demand'], $params['respectEnableFields'], $params['query'], $params['constraints']);
}
/**
* @param \GeorgRinger\News\Domain\Model\Dto\NewsDemand $demand
* @param bool $respectEnableFields
* @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
* @param array $constraints
*/
protected function updateConstraints($demand, $respectEnableFields, \TYPO3\CMS\Extbase\Persistence\QueryInterface $query, array &$constraints)
{
//$constraints[] = $query->like('title', '%' . $subject . '%');
//$constraints[] = $query->equals('related', 0);
//echo $query->matching($query->contains('likedPosts', $post))->count();
}
}
I’m having trouble setting constraints here. I want to filter, so in all places, news that have relatedfrom
set, are not shown. For some reason, relatedfrom
is empty in the database, but in TYPO3 I can freely loop through it.
I’ve through about just using javascript and remove them, but that would break pagination.
Do I have to build a custom controller? If yes – I can’t find any way, how I could just “extend” the existing one (e.g. the extended controller would just call the paren’t methods and modify the output if required).