[英]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.