Skip to content

Instantly share code, notes, and snippets.

@ErHaWeb
Last active May 13, 2024 11:40
Show Gist options
  • Save ErHaWeb/d0d7e82cbf3e0699a22be4a531fa2a01 to your computer and use it in GitHub Desktop.
Save ErHaWeb/d0d7e82cbf3e0699a22be4a531fa2a01 to your computer and use it in GitHub Desktop.
Enhance Transl.Orig display

Display uid beside content title in select field "Transl.Orig" tt_content.l18n_parent

To find back to the connected mode in case of inconsistent content ("mixed mode") it is an editorial help if the unique id uid of content elements in the selection field "Transl.Orig" tt_content.l18n_parent is displayed regardless of whether debug mode is activated and the admin status of the backend user.

To achieve this, place this file in your sitepackage under: EXT:sitepackage/Classes/User/Tca.php and add the following line in EXT:sitepackage/Configuration/TCA/Overrides/tt_content.php:

$GLOBALS['TCA']['tt_content']['ctrl']['label_userFunc'] = Tca::class . '->labelWithUid';

This user function returns the title considering the tables ctrl settings label and label_alt since it uses exactly the same function BackendUtility::getRecordTitle in the first step before appending the uid.

If the backend user has the admin status and the debug mode has been activated, this user function has no effect on the output, since the uid is already displayed after the title by default.

If required, this user function can also be used for other tables. To achieve this, simply replace tt_content with the name of the table.

<?php
declare(strict_types=1);
/**
* EXT:sitepackage/Classes/User/Tca.php
*/
namespace VendorName\Sitepackage\User;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
class Tca
{
/**
* @param $parameters
* @return void
*/
public function labelWithUid(&$parameters): void
{
unset($GLOBALS['TCA'][$parameters['table']]['ctrl']['label_userFunc']);
$parameters['title'] = BackendUtility::getRecordTitle($parameters['table'], $parameters['row']);
if (!(($GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] ?? false) && $this->getBackendUser()->isAdmin())) {
$parameters['title'] .= ' [' . $parameters['row']['uid'] . ']';
}
$GLOBALS['TCA'][$parameters['table']]['ctrl']['label_userFunc'] = __CLASS__ . '->labelWithUid';
}
/**
* Returns the current BE user.
*
* @return BackendUserAuthentication
*/
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
<?php
declare(strict_types=1);
/**
* EXT:sitepackage/Configuration/TCA/Overrides/tt_content.php
*/
use VendorName\Sitepackage\User\Tca;
defined('TYPO3') or die();
(static function () {
$GLOBALS['TCA']['tt_content']['ctrl']['label_userFunc'] = Tca::class . '->labelWithUid';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment