Reputation: 4076
I've been trying to remove the "Miscellaneous Scripts" (set in System > Configuration > General > Design > HTML Head > Miscellaneous Scripts
) for a particular CMS page. I've gone to CMS > Pages > Design > Page Layout > Layout Update XML
and entered the following code:
<reference name="head">
<remove name="miscellaneous-scripts"/>
</reference>
This doesn't seem to remove the code from the CMS page. I've tried similar variations such as "header" instead of "head", however, none have worked as of yet. Will somebody please help me in achieving this? Can this successfully be done using this method? Thank you in advance for any constructive contributions!
Upvotes: 3
Views: 2560
Reputation: 91
You can remove directly from layout, but in you example you write wrong xml for remove this block.
This block is in container="before.body.end"
and name of "Miscellaneous Scripts" is "absolute_footer"
<referenceContainer name="before.body.end">
<referenceBlock name="absolute_footer" remove="true" />
</referenceContainer>
Upvotes: 0
Reputation:
I "invented" a simple trick to remove misc-html from cms or whatever:
In the content insert the following html code:
<style>
.misc-html {display:none}
</style>
Upvotes: 0
Reputation: 4076
As per Evan's answer, I have decided to directly edit the template page. I needed to exclude the "Miscellaneous Scripts" on the "Empty" layout. So I went to /app/design/frontend/theme/default/template/page/empty.phtml
. From there, I did a string replace to remove the code from getChildHtml('head').
Changed:
echo $this->getChildHtml('head');
To this:
$headcode = str_replace('<script type="text/javascript" ...>', '', $this->getChildHtml('head'));
echo $headcode;
Now, the code will be excluded only from empty.phtml.
Upvotes: 0
Reputation: 457
Misc. scripts are made available via Mage/Page/Block/Html/Head getIncludes()
which is called from template/page/html/head.phtml. Because it's called directly from the template and not via getChildHtml(), you can't use layout xml to remove it using a <remove name... />
tag.
You could set a new head.phtml template which doesn't call getIncludes() for that CMS page using layout. Or you could rewrite Html/Head.php and expose a method for disabling includes.
Upvotes: 1