[英]Add Custom Button to Joomla's Article Editor (TinyMCE)
我正在嘗試在Joomla的文章編輯器中插入一個額外的按鈕。 它在擴展模式下使用默認的TinyMCE插件。 您已經知道編輯器下面有4個按鈕(文章,圖像,分頁和閱讀更多)。 我想做的是插入第5個按鈕。 (我確實附上了一個圖像按鈕,所以說我不能發帖,至少需要10個重復點。)
我曾嘗試復制分頁按鈕插件並重命名等,然后將其重新安裝為新插件,但所有這一切都會導致TinyMCE出錯,並且不會出現任何按鈕。
問題 :如何插入按鈕?
我繼續進行廣泛的搜索,並找到了一個關於為Joomla 1.5的文章編輯器添加額外按鈕的指南。
該教程可從以下網址獲得: http : //tushev.org/articles/programming/18-how-to-create-an-editor-button-editors-xtd-plugin-for-joomla 。
開箱即用,這對於Joomla 2.5和Joomla 3.0無效,因為XML清單標准已經發生了如此微小的變化。 與教程保持一致使用此XML清單。
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" method="upgrade" group="editors-xtd">
<name>test</name>
<author>Name</author>
<creationDate>Month 2013</creationDate>
<copyright>Month Name. All rights reserved.</copyright>
<license>GPL</license>
<authorEmail>Email</authorEmail>
<authorUrl>Your URL</authorUrl>
<version>1.0.0</version>
<description>
"adds the button 'test' to the editor"
</description>
<files>
<filename plugin="test">test.php</filename>
</files>
</extension>
PHP教程是正確的,如下所示:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgButtonTest extends JPlugin {
function plgButtonTest(& $subject, $config)
{
parent::__construct($subject, $config);
}
function onDisplay($name)
{
$js = "
function buttonTestClick(editor) {
txt = prompt('Please enter something','123');
if(!txt) return;
jInsertEditorText('{test '+txt+'}', editor);
}";
$css = ".button2-left .testButton {
background: transparent url(/plugins/editors-xtd/test.png) no-repeat 100% 0px;
}";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration($js);
$doc->addStyleDeclaration($css);
$button = new JObject();
$button->set('modal', false);
$button->set('onclick', 'buttonTestClick(\''.$name.'\');return false;');
$button->set('text', JText::_('Test'));
$button->set('name', 'testButton');
$button->set('link', '#');
return $button;
}
}
?>
感謝大家的幫助。 如果您有任何其他更好的方法,我將非常感激。
如果您的插件安裝成功,那么您必須將您的插件名稱放入tinymce
Custom plugin
的高級參數設置中的Custom plugin
和Custom button
。並確保已發布已安裝的插件。例如,請參見下圖。
這是我的自定義插件已設置為啟用。請看這個圖片:
然后在tinymce
插件中轉到高級參數,最后看到有自定義字段選項。請看這個圖像:
輸入插件名稱和按鈕名稱。在文章管理器編輯器中找到您的按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.