César Dueñas
César Dueñas

Reputation: 331

How send a variable parameter in user function for typoscript

I have been trying to send a variable parameter to my User Function of this way

userFunc = user_ttNewsCategoriesByUID
param1 = GP:tx_ttnews|tt_news

but doesn't work. What is the correct form to send a variable parameter, in this case uid of a tt_news. For use it in my PHP code, something like this

function user_ttNewsCategoriesByUID($content='', $conf=array()) {
     .........
     $getUIdOfNew = $conf['param1']      
     .........
}

Upvotes: 1

Views: 897

Answers (1)

jokumer
jokumer

Reputation: 2269

TypoScript

10 = USER_INT 
10 {
  userFunc = Vendor/MyExt/Userfunccollection->user_ttNewsCategoriesByUID
}

PHP class Userfunccollection

/**
 * Get TtNewsCategoriesByUID
 *
 * @param string Input string
 * @param array Config
 * @return void
 */
function user_ttNewsCategoriesByUID($content, $conf) {
    $tt_news = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tx_ttnews');
    $tt_news_uid = intval($tt_news['tt_news']);
    ...
}

Upvotes: 1

Related Questions