*/ class AddJavaScriptFileViewHelper extends AbstractViewHelper { /** * Register the ViewHelper arguments */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('javaScriptFile', 'string', 'The JavaScript file to include', TRUE); } /** * Adds a custom javascript file * * @return void */ public function render() { $javaScriptFile = (\TYPO3\CMS\Core\Http\ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend() ? $this->getBaseUrl() : '') . $this->arguments['javaScriptFile']; $this->getPageRenderer()->addJsFile($javaScriptFile); } }