I have a realurl2 configuration which requires me to change the title of a given category by a selected language. The kicker is there is only one Database Record with the category title and the translation is made trough .xlf files.
I managed to replace the title now, however the mapping obviously does not work. Is there a method within the realurl Classes which could easily add a database record or am I stuck decoding it myself within the $_GET Paramaeters?
'fixedPostVars' => array(
// TODO: Implement dynamic via typoscript if possible!
'3' => array(
array(
'GETvar' => 'tx_products_products[product_categories]',
'userFunc' => function(&$params, $ref) use ($recordTranslator){
$categoryId = $params['value'];
$translation = $recordTranslator->render('Category', 'title', $categoryId, 'products');
$realUrlConf = new \DmitryDulepov\Realurl\Configuration\ConfigurationReader(0, $params);
$realUrlUtil = new \DmitryDulepov\Realurl\Utility($realUrlConf);
$translation = $realUrlUtil->convertToSafeString($translation);
return $translation;
}
),
This is what I have coded so far. The recordTranslator here just returns the String I want to use within the url.
I ended up pre filling my "tx_realurl_uniqalias" table with aliases, field, uid, language, etc.
The Translated Alias still was created trough
$realUrlConf = new \DmitryDulepov\Realurl\Configuration\ConfigurationReader(0, $params);
$realUrlUtil = new \DmitryDulepov\Realurl\Utility($realUrlConf);
$translation = $realUrlUtil->convertToSafeString($translation);
I mapped my Iso language tags to the spoken language prior to this. For that I created a typoscript object within my settings.
de {
ch-de = 1
de-de = 3
at-de = 5
}
en {
de-en = 4
}
fr {
ch-fr = 2
}
no {
no = 6
}
and saved the language field provided by the realurl_conf to filter the translation. Like so:
'GETvar' => 'L',
'valueMap' => array(
'ch-de' => '1',
'ch-fr' => '2',
'de-de' => '3',
'de-en' => '4',
'at-de' => '5',
'no' => '6',
),
'noMatch' => 'bypass',
I still have to clear my SpokenUrl Aliases within the backend whenever a new "Database Record" is created and rebuild it with the refreshed data but it works.
The lookup is the usual lookuptable format:
array(
'GETvar' => 'tx_products_products[product_categories]',
'lookUpTable' => array(
'table' => 'tx_products_domain_model_category',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),