4

I know I can configure tt_news to automatically set author and email to a given value, like this:

TCAdefaults.tt_news.author = full name
TCAdefaults.tt_news.author_email = name@domain.tld

But could I retrieve the name an email from the info of the currently logged BE user instead?

Charles Brunet
  • 21,797
  • 24
  • 83
  • 124

2 Answers2

2

To meake it possible to fill the values on every change (if empty), you need to register a hook somewhere ie, in your own extension

typo3conf/ext/yourext/hooks/class.tx_ttnews_hooks.php

class tx_ttnews_hooks {
// hook for prefilling TCA values
function getSingleField_preProcess($table, $field, &$row, $altName, $palette, $extra, $pal, $pObj) {

        switch($field) {
            case 'author_email':
                if($row[$field] == '') {
                    $row[$field] = $GLOBALS['BE_USER']->user['email'];
                }
                break;

            case 'author':
                if($row[$field] == '') {
                    $row[$field] = $GLOBALS['BE_USER']->user['realName'];
                }
                break;
         }
    }
}

and then add this into typo3conf/ext/yourext/ext_localconf.php:

$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'][] 
    = 'EXT:yourext/hooks/class.tx_ttnews_hooks.php:tx_ttnews_hooks';
biesior
  • 55,576
  • 10
  • 125
  • 182
0

There is an extension that does what you want. I haven't used it myself, but the description sounds pretty promising.

As another solution, you may write a little bit of php code that adds a dynamic user ts. I only found an example in German, but maybe that's helpful anyway.

Michael
  • 2,309
  • 1
  • 23
  • 34