Static Magento Blocks. Remove wrapper <p>

When I create a static block, magento wraps the contents with <p> tags. Which is very bad for the DOM. Is it possible to somehow remove it. I assume this is some kind of javascript, but I don't know which one.

+3
source share
4 answers

Actually wrong in my earlier answer.

You need to rotate the default WYSIWYG editor static block.

Go to the "System β†’ Configuration" section, find the "General" section on the left, click "Content Management" and set "Enable WYSIWYG Editor" to "Disable by default" from the list.

Then carefully edit your static blocks - use WYSIWYG, but then check your HTML.

This is a standard feature of WYSIWYG editors, for which they are used, <p> tags are added because they make beautifully formatted text. Clearly, this is not what you want if you add a static block containing only the image, so exit the editor and check the <p> tags.

The WYSIWYG editor can also cripple variables entered into static blocks and slows down the loading time of the admin page, so it’s best to turn it off by default.

+13
source

A more user-friendly way would be to catch cms_page_render -event and use the regex to "expand" the widget:

configurations:

 <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> 

observer:

 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); } 

This will disable the widget from their paragraphs before they execute Magento.

Edit: the part between {{and}} must be inanimate.

+5
source

edit 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, 
+4
source

It depends on where you use your static blocks and which templates / themes you use. Turn on the developer interface hints, upload your malicious pages, determine which template file to use, and pull out the <p> tabs from your phtml files.

A directly called static block does not place additional <p> tags.

+3
source

All Articles