Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created February 1, 2017 12:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedricziel/95bd6ddbe595ead078bd0c7bc6e3dd53 to your computer and use it in GitHub Desktop.
Save cedricziel/95bd6ddbe595ead078bd0c7bc6e3dd53 to your computer and use it in GitHub Desktop.
Find all plugins of a specific type and attach fixedPostVars to them
<?php
namespace My\Ext\Hooks;
use TYPO3\CMS\Backend\Utility\BackendUtility;
class RealUrlAutoconfHook {
/**
* @param array $params
* @param $pObj
*
* @return array
*/
public function addRealUrlConfiguration($params, &$pObj)
{
$params = array_merge_recursive(
$params['config'],
[
'fixedPostVars' => [
'findConfiguration' => [
[
'GETvar' => 'tx_find_find[mangled][country]',
'lookUpTable' => [
'table' => 'static_countries',
'id_field' => 'uid',
'alias_field' => 'cn_short_de',
'useUniqueCache' => true,
'useUniqueCache_conf' => [
'strtolower' => true,
'spaceCharacter' => '-',
],
'enable404forInvalidAlias' => true,
],
],
],
],
]
);
$params = $this->addFixedPostVarsForPlugins($params, $pObj);
return $params;
}
/**
* @param array $params
* @param $pObj
*
* @return array
*/
protected function addFixedPostVarsForPlugins($params, &$pObj)
{
$findPlugins = BackendUtility::getRecordsByField(
'tt_content',
'list_type',
'find_find',
'AND CType="list" '
);
if ($findPlugins !== false) {
foreach ($findPlugins as $plugin) {
$params['fixedPostVars'][$plugin['pid']] = 'findConfiguration';
}
}
return $params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment