| 
       
	magento后台的cms页面,static block编辑时可以使用TinyMCE所见即所得编辑器。默认情况下,magento不管哪个版本都是不支持在TinyMCE中使用style,link,script,iframe等一些会影响页面安全或会导致页面无法使用的标签,毕竟这些标签可能导致整个页面布局错乱掉。 
	但是实际情况是,普通用户使用magento的static block制作专题页面时还是要借助到这些标签。你可能会说它不是用个显示html源代码的按钮,直接将代码复制进去就行了,但是很快你会发现,你贴进去的代码中所有的style,link,script,iframe标签会被过滤掉。也就是默认magento是不允许在TinyMCE所见即所得编辑器使用这些标签。 
	如果要允许在TinyMCE所见即所得编辑器使用这些标签,编辑 
	js/mage/adminhtml/wysiwyg/tiny_mce/setup.js 
	在97行可以找到TinyMCE所见即所得编辑器的配置参数数组setting,给这个数组添加一个key为extended_valid_elements的元素,值就是你要允许使用的标签,用逗号分隔,如 
	j 
	extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script[type|src],link[rel|type|media|href]', 
	改后setting数组大致是 
	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, 
	            extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script[type|src]', 
	进入magento后台,清空一下缓存可能需要,刷新一下页面,再次将html源代码贴到TinyMCE所见即所得编辑器是不会被过滤提style,这些标签。需要注意的是,要指定对应标签的属性,不然这些属性还是会被过滤掉。 
      
      (责任编辑:最模板) |