Typo3 RealURL:带有前导零的UID

时间:2014-10-01 13:05:31

标签: php typo3 realurl leading-zero

假设以下Typo3 RealURL设置:

'news' => array(
        array(
                'GETvar' => 'tx_news_pi1[action]',
        ),
        array(
                'GETvar' => 'tx_news_pi1[controller]',
        ),
        array(
                'GETvar' => 'tx_news_pi1[news]',
                'lookUpTable' => array(
                        'table' => 'tx_news_domain_model_news',
                        'id_field' => 'uid',
                        'alias_field' => 'CONCAT(title, "-", uid)',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-',
                        ),
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                        'autoUpdate' => 1,
                        'expireDays' => 180,
                ),
        ),
),

关于这一行:'alias_field' => 'CONCAT(title, "-", uid)',

我需要将前导零添加到uid,因此它至少有三位数。

在数组之外,它将是:$uid = sprintf('%03d', $uid);

1 个答案:

答案 0 :(得分:2)

您可以使用MySQL函数LPAD()

看起来像这样:

'alias_field' => "CONCAT(title, '-', LPAD(uid, 3,'0'))",