typo3typoscripttypo3-6.2.xtt-news

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']      
     .........
}

Solution

  • 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']);
        ...
    }