# userFuncs with cObject ## Introduction It's very easy to extend powermail with cObject Viewhelpers, which are calling a userFunc from TypoScript. ## Where can you use cObject Viewhelpers in powermail - In every HTML Template (and Partial and Layout) - In every RTE field in flexform - In the subject, receiver, receiverName, sender, senderName field of the flexform ## What can you do with this flexibility If you need to call a userFunc after submitting a form or if you need dynamic text in a view. Some examples: - Create an extension for transaction keys in powermail - Manipulate the receiver from a userFunc depending on a field value (see below) - Log something special in a database table after a submit - etc... ## Example to manipulate the receiver of a form ### With pure TypoScript #### Example Call in Flexform Settings ![developer_cobject](../Images/developer_cobject.png) #### Example call in TypoScript ``` # TypoScript Setup Example for ViewHelper {f:cObject(typoscriptObjectPath:'lib.test')} lib.test = TEXT lib.test.value = newReceiver@mail.com ``` ### With a userFunc on TypoScript depending on a field value #### Example Call in Flexform Settings ![developer_cobject](../Images/developer_cobject.png) #### Example call in TypoScript ``` # TypoScript Setup Example for ViewHelper {f:cObject(typoscriptObjectPath:'lib.test')} # Note: includeLibs does not work in TYPO3 8 any more. UserFuncs must be added in an own extension to use composer autoload. includeLibs.manipulatePowermailReceiver = typo3conf/ext/myext/Classes/ManipulateReceiver.php lib.test = USER lib.test.userFunc = Vendor\Myext\ManipulateReceiver->getEmail ``` ## Example PHP Script ```