2012-09-11 42 views
2

我想製作一個組件,我需要添加已安裝的Joomla的Tinymce編輯器!在那個組件中。如何在Joomla中添加tinymce! 2.5組件

我看着互聯網,但沒有找到任何例子。到現在爲止,我設法做的唯一事情就是下載tinymce的js文件並將其安裝到我的組件中。

但我知道Joomla已經在tinymce中創建了文件。那麼,如何使用它在我的組件代碼中,無需再次下載文件?

+1

http://forum.joomla.org/viewtopic.php?f=474&t=219145或http://stackoverflow.com/questions/2540807/how-do-i-make-textarea-a-tinymce -in-joomla 希望這有助於。我已經自己做了,只是尋找我的來源... – codeling

+0

是的,它似乎在工作,你可以鍵入它作爲答案。這個例子也適用於joomla 2.5 – themis

+1

我相信這個問題對joomla社區的編碼人員來說是有效和明確的,它不應該被關閉。這是一個真實而有效的問題 – themis

回答

4

你不需要任何TinyMCE的文件添加到您的組件;在你的模板,添加這些行:

$value = 'your desired text content'; 
$editor = JFactory::getEditor(); 
echo $editor->display('editorName', $value, '550', '400', '60', '20', false); 

爲了取回輸入文字而不會被剝離下來,使用下列之一:

$postData = JRequest::get('POST', JREQUEST_NOTRIM | JREQUEST_ALLOWRAW); 
$text = $postData['editorName']; 

$text = JRequest::getVar('editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW); 

或,從1.6開始,上面的方法似乎不推薦使用(參見here,也是下面代碼的來源),新方法將是:

$jinput = JFactory::getApplication()->input; 
// Then use JInput's get() method with the filter you need: 
$description = $jinput->get('editorName', 'defaultValue', 'HTML'); 

在我的代碼中,就在提交表單之前,我也打電話給JEditor::save;我不知道這是否真的有必要;經過一番研究後,我並沒有真正發現它的用途,所以如果沒有它的話,它會對你有用,我會放棄它。

有一些類似的問題(例如this one)和論壇帖子(例如this one),但沒有全面的回答,據我所知,我是用,在一個點過掙扎,這就是爲什麼我回答得相當長。

+0

謝謝你,你的回答真的很有幫助 – themis

3
$editor  =& JFactory::getEditor(); 
    $editor_tiny = $editor->display('product_section_table[]',$setiontable[$i] ,'95%', '550', '75', '20', false); 
    echo $editor_tiny; 

您可以使用此代碼也

+0

是的這個作品 – themis

+0

嗨它的工作,但只添加textarea ..............請給點意見...... ... –