我正在使用Magento2与fpc,清漆,redis和封装盒,我面临着一个非常奇怪的行为,因为一个损坏的html内容。我有一个phtml文件,其中包含一些php,后跟javascript,如下所示:
<div class="some-class">
<!--html -->
</div>
<script>
//...
$element.wrap('<div class="red"></div>');
//..
</script>在父模板(也是phtml文件)中,使用php include (是的,这就是Magento核心模块在不使用块的情况下包含它的方式)将该文件包含为:
<?php include 'path/to/file.phtml'; ?>问题是,在页面源代码上,我得到了以下意想不到的html:
<div class="some-class">
<!--html -->
</div>
<script>
//...
$element.wrap('<div class="red"></script></div>');
//..broken content here due to the moved script tag请注意移动的结束标记..
我知道这种情况可能是由几个问题引起的,但我怀疑是因为只有在发生问题的环境中才会使用它
请建议与缓存相关的可能情况,任何帮助或想法都是感激的。
谢谢
发布于 2020-03-23 06:44:30
尝试使用此方法在phtml中回显其他phtml。
<?php
echo $block->getLayout()
->createBlock("Magento\Framework\View\Element\Template")
->setTemplate("Your_Module::file.phtml")
->toHtml();
?>https://stackoverflow.com/questions/60766152
复制相似问题