[TYPO3-ttnews] news: how to add a custom constraint in repository? [SOLVED]

Stefano Cecere scecere at krur.com
Wed Feb 27 01:46:18 CET 2013


to give back the help received here is how i solved adding a custom 
constraint (George maybe yo ucan add it to the manual?)

in ext_localconf.php add the hook registration:

$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Domain/Repository/AbstractDemandedRepository.php']['findDemanded'][] 
= 
'EXT:myext/Classes/Hooks/class.tx_news_hooks.php:tx_news_hooks->generateQuery';

in class.tx_news_hooks.php i just added:

class tx_news_hooks {

	function generateQuery($params, $pObj) {
		
		$myparam = 
intval($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_myext.']['settings.']['myparam']);

		$params['constraints'][] = $params['query']->equals('customselector', 
$myparam);

	return;
	}	
}




$site = 
intval($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ucimu.']['settings.']['site.']['pid']);


On 27/02/13 00:39, Stefano Cecere wrote:
> well.. in Georg blog i find this:
>
> If you want to change the generated query, there is a hook for that. Use
> $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Domain/Repository/AbstractDemandedRepository.php']['findDemanded']
> for that.
>
> i think it's what's to be used.. i'll let you know! :)
>
>
>
> On 27/02/13 00:29, Stefano Cecere wrote:
>> Hi
>>
>> what if i want to add to the news repository
>> createConstraintsFromDemand() an additional constraint with a value from
>> typoscript?
>>
>> something like:
>>
>> $constraints[] = $query->contains('customselector',
>> $settings['selected_value']);
>>
>> do you think it's easily possibile, or should i go with a full
>> personalized action + repo search?
>
>


-- 

-- --- ----- -------

Stefano Cecere
KRUR studio - http://krur.com


More information about the TYPO3-project-tt-news mailing list