Magento删除"杂项脚本"来自CMS Page

时间:2015-12-14 16:04:38

标签: xml magento

我一直试图删除"杂项脚本" (在System > Configuration > General > Design > HTML Head > Miscellaneous Scripts中设置)以查找特定的CMS页面。我已转到CMS > Pages > Design > Page Layout > Layout Update XML并输入以下代码:

<reference name="head">
   <remove name="miscellaneous-scripts"/>
</reference>

这似乎无法从CMS页面中删除代码。我尝试过类似的变体,例如&#34; header&#34;而不是&#34; head&#34;但是,还没有人工作过。有人请帮我实现这个目标吗?可以使用这种方法成功完成吗?提前感谢您的任何建设性贡献!

4 个答案:

答案 0 :(得分:1)

混杂。脚本通过optional提供 从Mage/Page/Block/Html/Head getIncludes()调用。因为它是直接从模板而不是通过getChildHtml()调用的,所以不能使用layout xml来使用Dim cel as range For each cel in Range("A1:A" & Range("A1").end(xldown).row if cel.value = "Planned:" then cel.resize(1,60).cut cel.offset(-1,4).pastespecial xlpasteall end if next cel 标记将其删除。

您可以设置一个新的head.phtml模板,该模板不会使用布局为该CMS页面调用getIncludes()。或者你可以重写Html / Head.php并公开一种禁用包含的方法。

答案 1 :(得分:0)

根据Evan的回答,我决定直接编辑模板页面。我需要在“Empty”布局中排除“Miscellaneous Scripts”。所以我去了/app/design/frontend/theme/default/template/page/empty.phtml。从那里,我做了一个字符串替换,从getChildHtml('head')中删除代码。

更改:

echo $this->getChildHtml('head');

对此:

$headcode = str_replace('<script type="text/javascript" ...>', '', $this->getChildHtml('head'));
echo $headcode;

现在,代码将仅从empty.phtml中排除。

答案 2 :(得分:0)

我“发明了”从cms或其他任何东西中移除misc-html的简单技巧:

在内容中插入以下html代码:

<style>
.misc-html {display:none}
</style>

答案 3 :(得分:0)

您可以直接从布局中删除,但在您的示例中,您为删除此块编写了错误的 xml。 此块位于 container="before.body.end" 中,“杂项脚本”的名称为“absolute_footer”

<referenceContainer name="before.body.end">
    <referenceBlock name="absolute_footer" remove="true" />
</referenceContainer>