Open gmpf opened 6 years ago
How to reproduce:
Add this to system/config/dcaconfig.php
or app/Resources/contao/dca/tl_page.php
:
$GLOBALS['TL_DCA']['tl_page']['subpalettes']['protected'] = 'groups,mcwIssue';
$GLOBALS['TL_DCA']['tl_page']['fields']['mcwIssue'] = [
'label' => ['Test MCW issue',''],
'inputType' => 'multiColumnWizard',
'eval' => [
'columnFields' => [
'col1' => [
'label' => 'Foo or bar?',
'inputType' => 'select',
'options' => ['foo', 'bar']
],
'col2' => [
'label' => 'Baz or boing?',
'inputType' => 'select',
'options' => ['baz', 'boing']
]
]
]
];
Edit any regular, non-protected page. If you look at the page source, you can see that the MultiColumnWizard CSS and JS aren't there.
Toggle the protected
subpalette by selecting "Protect page" (de: "Seite schützen").
It looks like this in Contao 4.4:
Contao 3.5:
When the subpalette-triggering field is already saved as active, the MCW widget is generated and the CSS is loaded:
Contao 4.4 with CSS loaded:
Contao 3.5:
(The selects look kind of wrong as well, but that's a different issue.)
system/modules/multicolumnwizard/html/js/multicolumnwizard_be(_src).js
andsystem/modules/multicolumnwizard/html/css/multicolumnwizard(_src).css
are intended to be loaded in the backend no matter whether a MultiColumnWizard widget is loaded or not, for example in case the field is initially hidden because it is part of a subpalette.However, this doesn't happen because the addition of CSS and JS was rendered ineffectual by https://github.com/menatwork/MultiColumnWizard/pull/213.
The asset paths are added to
$GLOBALS['TL_CSS']
and$GLOBALS['TL_JAVASCRIPT']
in aparseTemplate
hook: https://github.com/menatwork/MultiColumnWizard/blob/786f2528f3ba345391644b4aeda86096d4957dc9/system/modules/multicolumnwizard/MultiColumnWizardHelper.php#L31-L47 However, that hook is called fromTemplate::parseTemplate
after the head tags have already been rendered and added to the template inBackendTemplate::output
: https://github.com/contao/core/blob/d883f04807500b5f5c65bf9dd927c38e60812e42/system/modules/core/classes/BackendTemplate.php#L61-L92 Adding anything to those asset arrays inparseTemplate
therefore has no effect.I'm not sure about which way to go in solving this. I can see two approaches at the moment:
config.php
and we detect the install/login pages differently. Something like this (untested):if (TL_MODE == 'BE' && $addBackendAssets) { $GLOBALS['TL_JAVASCRIPT']['mcw'] = $GLOBALS['TL_CONFIG']['debugMode'] ? 'system/modules/multicolumnwizard/html/js/multicolumnwizard_be_src.js' : 'system/modules/multicolumnwizard/html/js/multicolumnwizard_be.js'; $GLOBALS['TL_CSS']['mcw'] = $GLOBALS['TL_CONFIG']['debugMode'] ? 'system/modules/multicolumnwizard/html/css/multicolumnwizard_src.css' : 'system/modules/multicolumnwizard/html/css/multicolumnwizard.css'; }
Disadvantages: Duplication of core code. Also, I think we end up with those tags appearing twice if the widget is loaded as well.