2011-04-08 83 views
1

我有一個symfony窗​​體,其中使用了tinyMCE的「contents」textarea。TinyMCE刪除youtube鏈接

當我寫:

<p class="centre"> 
<object width="640" height="385"> 
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0"> 
</param> 
<param name="allowFullScreen" value="true"> 
</param> 
<param name="allowscriptaccess" value="always"> 
</param> 
<embed src="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"> 
</embed> 
</object> 
</p> 

將保存爲:

<p class="centre"> 
<object width="640" height="385"> 
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&amp;hl=en_US&amp;fs=1&amp;rel=0" /> 
<param name="allowFullScreen" value="true" /> 
<param name="allowscriptaccess" value="always" /> 
</object> 
</p> 
+1

發現你與螢火檢查呢?因爲它有時會自動糾正無效的html。通過使用「查看源代碼」方法或wget,確保這是真正的HTML。 – greg0ire 2011-04-08 13:36:35

+0

即使在保存之前,tinymce也會刪除該html。所以這不是symfony的錯,我的不好。 – Manu 2011-04-08 13:56:02

回答

1

我不得不添加一些元素* extended_valid_elements *,以便它不會刪除Flash內容。

tinyMCE.init({ 
    mode : 「textareas」, 
    editor_selector:「mceEditor」, 
    theme : 「advanced」, 
    theme_advanced_buttons1 : 「bold,italic,underline,strikethrough,|,forecolor,backcolor,|,link,unlink,image,code」, 
    theme_advanced_buttons2 : 「」,theme_advanced_buttons3 : 「」,theme_advanced_buttons4 : 「」, 
    theme_advanced_resizing : true, tab_focus : 「:prev,:next」, 
    extended_valid_elements : 「object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]「 
}); 

回答http://syedgakbar.wordpress.com/2008/01/28/adding-flash-embed-support-in-tinymce-editor/

1

只需添加您的init配置陣列的closed鍵內param標籤:

tinyMCE.init({ 
    ... 
    closed: /^(br|hr|input|meta|img|link|param|area|param)$/, 
    ... 
}); 

Source

+0

嗯,我可能有一個地方的錯誤,但如果我刪除第二行,html代碼被從內容字段 – Manu 2011-04-08 13:52:52

+0

剝離你是否使用常量「ESC_RAW」作爲getContents方法的參數? – Phen 2011-04-08 13:58:34

+0

nope.But但我發現刪除HTML是tinyMCE的做,而不是symfony – Manu 2011-04-08 14:03:13