Magento静态块。除去包装

| 当我创建静态块时,magento用with0ѭ标签包装内容。这对DOM非常不利。 可以通过某种方式将其删除。我想这是一些JavaScript,但我不知道是哪一个。     
已邀请:
        我先前的回答实际上是错误的。 您需要默认关闭静态块WYSIWYG编辑器。 转到系统->配置,在左侧找到“常规”部分,单击“内容管理”,然后从列表中将“启用所见即所得编辑器”设置为“默认情况下禁用”。 然后仔细编辑您的静态块-使用所见即所得,但事后检查HTML。 此行为是所见即所得(WYSIWYG)编辑器的标准功能,这就是它们的用途,添加了
<p>
标记是因为它们可以很好地格式化文本。显然,如果添加仅包含图像的静态块,那么这不是您想要的,因此请退出编辑器并检查“ 0”标签。 WYSIWYG编辑器还可以处理输入到静态块中的变量,这会减慢管理页面的加载时间,因此最好将其默认关闭。     
        一种更加用户友好的方法是捕获
cms_page_render
事件,并使用正则表达式对小部件进行“解包”: 配置:
<cms_page_render>
    <observers>
        <your_unique_handler>
            <type>singleton</type>
            <class>Package_Module_Model_Observer</class>
            <method>cmsPageRenderEvent</method>
        </your_unique_handler>
    </observers>
</cms_page_render>
观察者:
public function cmsPageRenderEvent($observer)
{
    /* @var $page Mage_Cms_Model_Page*/
    $page = $observer->getPage();

    // Remove wrapping paragraphs around widgets:
    $content = $page->getContent();
    $content = preg_replace(\'/\\<p\\>{{(.*?)}}\\<\\/p\\>/\', \'{{$1}}\', $content);
    $page->setContent($content);
}
这将在Magento执行之前将小部件从其段落中展开。 编辑:{{和}}之间的部分应该是非贪婪的。     
        编辑js / mage / adminhtml / wysiwyg / tiny_mce / setup.js
var settings = {
        mode : (mode != undefined ? mode : \'none\'),
        elements : this.id,
        theme : \'advanced\',
        plugins : plugins,
        theme_advanced_buttons1 : magentoPlugins + \'magentowidget,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect\',
        theme_advanced_buttons2 : \'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor\',
        theme_advanced_buttons3 : \'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,ltr,rtl,|,fullscreen\',
        theme_advanced_buttons4 : \'insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak\',
        theme_advanced_toolbar_location : \'top\',
        theme_advanced_toolbar_align : \'left\',
        theme_advanced_statusbar_location : \'bottom\',
        theme_advanced_resizing : true,
        convert_urls : false,
        relative_urls : false,



        forced_root_block : \'\', /* <-- Add this setting */



        content_css: this.config.content_css,
        custom_popup_css: this.config.popup_css,
        magentowidget_url: this.config.widget_window_url,
        magentoPluginsOptions: magentoPluginsOptions,
    
        这取决于您在何处使用静态块以及所使用的模板/主题。打开开发人员前端提示,加载有害页面,标识使用的模板文件,然后从phtml文件中拉出“ 0”选项卡。 直接调用的静态块不会放入额外的“ 0”标签。     

要回复问题请先登录注册