简体   繁体   English

Typo3 RealURL:带前导零的UID

[英]Typo3 RealURL: UID with leading zeros

Assuming the following Typo3 RealURL setup: 假设以下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,
                ),
        ),
),

It's about this line: 'alias_field' => 'CONCAT(title, "-", uid)', 关于这一行: 'alias_field' => 'CONCAT(title, "-", uid)',

I need to add leading zeros to uid , so it has at least three digits. 我需要在uid上添加前导零,因此它至少具有三位数。

Outside of an array, it would be: $uid = sprintf('%03d', $uid); 在数组之外,它将是: $uid = sprintf('%03d', $uid);

You can use the MySQL function LPAD() 您可以使用MySQL函数LPAD()

It will look something like this: 它看起来像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM