Skip to content

Commit

Permalink
[BUGFIX] Ensure correct loading order in ModuleTemplate
Browse files Browse the repository at this point in the history
This change makes sure to set up the page in the TYPO3 Backend,
to load JS and CSS directly in PageRenderer when the ModuleTemplate
object is instantiated, allowing to load custom JavaScript or CSS.

Before, renderContent (the last call in ModuleTemplate) was
used to add default CSS and JS.

Resolves: #91812
Releases: master, 10.4
Change-Id: I87c8392d3784d3ac63a086846e85fae76663d4a2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65236
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Marcus Schwemer <ms@schwemer.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Marcus Schwemer <ms@schwemer.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
bmack authored and ervaude committed Aug 22, 2020
1 parent fad2d6c commit a0231cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions typo3/sysext/backend/Classes/Template/ModuleTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ public function __construct(
$this->iconFactory = $iconFactory;
$this->flashMessageService = $flashMessageService;
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
$this->setupPage();
$this->loadJavaScripts();
$this->loadStylesheets();
}

/**
Expand Down Expand Up @@ -363,11 +366,8 @@ public function getDocHeaderComponent()
*/
public function renderContent()
{
$this->setupPage();
$this->pageRenderer->setTitle($this->title);
$this->loadJavaScripts();
$this->setJavaScriptCodeArray();
$this->loadStylesheets();
$this->pageRenderer->setTitle($this->title);

$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
if ($this->moduleId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function render()
$addJsInlineLabels = $this->arguments['addJsInlineLabels'];
$includeRequireJsModules = $this->arguments['includeRequireJsModules'];

$pageRenderer = $this->getPageRenderer();
$moduleTemplate = $this->getModuleTemplate();
$pageRenderer = $moduleTemplate->getPageRenderer();

// Include custom CSS and JS files
if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
Expand Down Expand Up @@ -111,7 +112,6 @@ public function render()
}
// Render the content and return it
$output = $this->renderChildren();
$moduleTemplate = $this->getModuleTemplate();
if ($this->arguments['enableDocHeader'] ?? false) {
$moduleTemplate->getDocHeaderComponent()->enable();
} else {
Expand Down

0 comments on commit a0231cf

Please sign in to comment.