Details
-
Bug
-
Resolution: Fixed
-
Medium
-
4.4.0, 4.5.0alpha
-
None
Description
Hi,
I have a template (page_head_dmv.tpl) that is included in pagelayout.tpl.
To be precise, the include is done this way:
{include uri='design:page_head.tpl'} {include uri='design:page_head_dmv.tpl'} {include uri='design:page_head_style.tpl'} {include uri='design:page_head_script.tpl'}
in my template page_head_dmv.tpl, I use ezcss_require, like this:
{ezcss_require('menu.css')}
It correctly works on a view full node for example, menu.css is bundled in the global minified css, built by ezjscore.
But in edit mode, all my requires (performed in page_head_dmv.tpl) are dropped !
Steps to reproduce
-
-
-
-
-
- When it works...
-
-
-
-
In fact, to give some information, by adding some logs in static function ezjscPackerTemplateFunctions::setPersistentArray(), the following test is true
if ( $tpl->hasVariable('module_result') ) { $isPageLayout = true; $moduleResult = $tpl->variable('module_result'); }
As a result $moduleResult is filled in (and $isPageLayout is true), and the next test is true also:
if ( isset( $moduleResult['content_info']['persistent_variable'] ) ) { $persistentVariable = $moduleResult['content_info']['persistent_variable']; }
And finally at the end of this function, as $moduleResult['content_info']['persistent_variable'] exists, the following code correctly filled in $moduleResult['content_info']['persistent_variable']:
if ( isset( $moduleResult['content_info']['persistent_variable'] ) ) { $moduleResult['content_info']['persistent_variable'] = $persistentVariable; $tpl->setVariable('module_result', $moduleResult ); }
Well all works there !
-
-
-
-
-
-
-
- When it DOESN'T work
However when I edit an object (www.domain.com/content/edit/383/1 for example), all my ezcss_require in my custom template page_head_dmv.tpl are lost...
- When it DOESN'T work
-
-
-
-
-
-
In fact, to give more explanations, in that case, all css from the module /content/edit are SUCCESSFULLY loaded first thanks to ezjscore
the following test is false:
if ( $tpl->hasVariable('module_result') ) { $isPageLayout = true; $moduleResult = $tpl->variable('module_result'); }
and the following is true:
else if ( $tpl->hasVariable('persistent_variable') ) { $persistentVariable = $tpl->variable('persistent_variable'); }
And at the end, as isPageLayout is false, the following code is executed, and correctly works (as $tpl->hasVariable('persistent_variable') is true):
$tpl->setVariable('persistent_variable', $persistentVariable );
AND AFTER comes the load of my css in my page_head_dmv.tpl (which is included in pagelayout.tpl), and things are going crazy here...
Whenever I use ezcss_require in page_head_dmv.tpl, the following test is true:
if ( $tpl->hasVariable('module_result') ) { $isPageLayout = true; $moduleResult = $tpl->variable('module_result'); }
BUT the following test is wrong:
if ( isset( $moduleResult['content_info']['persistent_variable'] ) ) { $persistentVariable = $moduleResult['content_info']['persistent_variable']; }
and the following test is true:
else if ( $tpl->hasVariable('persistent_variable') ) { $persistentVariable = $tpl->variable('persistent_variable'); }
And at the end, as $isPageLayout is true, the following code is executed, but it doesn't store anything as $moduleResult['content_info']['persistent_variable'] doesn't exist...:
if ( $isPageLayout ) { if ( isset( $moduleResult['content_info']['persistent_variable'] ) ) { $moduleResult['content_info']['persistent_variable'] = $persistentVariable; $tpl->setVariable('module_result', $moduleResult ); } }
=> As a result, my css required by ezcss_require is not stored anywhere ..... and this css is not put into the global minified css...
I really think that whenever $tpl->hasVariable('module_result') is true, a SECOND check has to be performed before really setting $isPageLayout to true
Indeed, a workaround for me was changing the code:
if ( $tpl->hasVariable('module_result') ) { $isPageLayout = true; $moduleResult = $tpl->variable('module_result'); }
TO:
if ( $tpl->hasVariable('module_result') ) { $moduleResult = $tpl->variable('module_result'); if ( isset( $moduleResult['content_info']['persistent_variable'] ) ) { $isPageLayout = true; } }
And then all works as expected for me...
Please confirm me this is a ezjscore bug, or maybe I've missed something...