Hoja
Hoja

Reputation: 1207

Add header and footer Data

In My Controller extbase extension. 6.2 I'm using

$GLOBALS['TSFE']->additionalFooterData[$this->extKey] .= '<script src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>';

Is there any better method for replacing this.

I know the API like //==== Include Js File Formatting ========

 $GLOBALS['TSFE']->getPageRenderer()->addJsFooterFile($jsFile, 'text/javascript', TRUE, FALSE, '', TRUE); 


//====  Include css File Formatting =======


 $GLOBALS['TSFE']->getPageRenderer()->addCssFile ( $cssFile, $rel = 'stylesheet', $media = 'all', $title = '',  $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $excludeFromConcatenation = FALSE, $splitChar = '|' );

But in terms of adding a custom data they cant be used, any thing else. Any opinion?.

Upvotes: 1

Views: 3947

Answers (1)

Jost
Jost

Reputation: 5840

There are three ways I'd consider:

  1. Build the styles and scripts separately using grunt or some other task runner, and then include the few resulting files globally. This is nice for complete websites, makes collaboration quite easy. Someone provides LESS styles, and you just compile and include them.
  2. Use this ViewHelper from EXT:vhs.
  3. Instead of using $GLOBALS['TSFE'], let extbase inject the page renderer into your code and then do what you are doing now.

    /**
     * @var \TYPO3\CMS\Core\Page\PageRenderer
     * @inject
     */
    protected $pageRenderer;
    

    (clear cache in the install tool after inserting this)

Upvotes: 4

Related Questions