0

Assuming the following Typo3 RealURL setup:

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

I need to add leading zeros to uid, so it has at least three digits.

Outside of an array, it would be: $uid = sprintf('%03d', $uid);

santa
  • 123
  • 9

1 Answers1

2

You can use the MySQL function LPAD()

It will look something like this:

'alias_field' => "CONCAT(title, '-', LPAD(uid, 3,'0'))",
konsolenfreddy
  • 9,551
  • 1
  • 25
  • 36