0

我有一个 realurl2 配置,它要求我通过所选语言更改给定类别的标题。关键是只有一个具有类别标题的数据库记录,并且翻译是通过 .xlf 文件进行的。

我现在设法替换了标题,但是映射显然不起作用。realurl 类中是否有一种方法可以轻松添加数据库记录,还是我自己在 $_GET 参数中对其进行解码?

'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;
                }
            ),

这是我到目前为止编码的内容。这里的recordTranslator 只是返回我想在url 中使用的字符串。

4

1 回答 1

0

我最终用别名、字段、uid、语言等预先填充了我的“tx_realurl_uniqalias”表。

翻译的别名仍然是通过创建的

                $realUrlConf = new \DmitryDulepov\Realurl\Configuration\ConfigurationReader(0, $params);
                $realUrlUtil = new \DmitryDulepov\Realurl\Utility($realUrlConf);
                $translation = $realUrlUtil->convertToSafeString($translation);

在此之前,我将我的 Iso 语言标签映射到口语。为此,我在我的设置中创建了一个打字稿对象。

de {
       ch-de = 1
       de-de = 3
       at-de = 5
     }
     en {
       de-en = 4
     }
     fr {
       ch-fr = 2
     }
     no {
       no = 6
     }

并保存 realurl_conf 提供的语言字段以过滤翻译。像这样:

'GETvar' => 'L',
        'valueMap' => array(
            'ch-de' => '1',
            'ch-fr' => '2',
            'de-de' => '3',
            'de-en' => '4',
            'at-de' => '5',
            'no' => '6',
        ),
        'noMatch' => 'bypass',

每当创建新的“数据库记录”并使用刷新的数据重建它时,我仍然必须在后端清除我的 SpokenUrl 别名,但它可以工作。

查找是通常的可查找格式:

 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' => '-',
                ),
            ),
        ),
于 2016-06-03T11:10:56.063 回答