将自定义按钮添加到Joomla的文章编辑器(TinyMCE) [英] Add Custom Button to Joomla's Article Editor (TinyMCE)
问题描述
我正在尝试在Joomla的文章编辑器中插入一个附加按钮.它在扩展模式下使用默认的TinyMCE插件.如您所知,编辑器下方有4个按钮(文章,图像,分页符和更多信息).我想做的是插入第5个按钮. (我确实附加了一个图像按钮,所以说我不能发布,因为至少需要10个代表点.)
I'm trying to insert an additional button in Joomla's article editor. It's using the default TinyMCE plug in Extended mode. As you'll already know there are 4 buttons underneath the editor (Article, Image, Page Break and Read More). What I'd like to do is insert a 5th button. (I did attach a image button SO said I can't post as need a minimum of 10 rep points.)
我尝试复制Page Break Button插件并重命名,等等,然后将其重新安装为新插件,但是所有这样做都会导致TinyMCE错误,并且没有按钮出现.
I have tried copying the Page Break Button plugin and renaming it etc, then re-installing it as a new plugin, but all that does it cause errors with TinyMCE and no button appears.
问题:如何插入按钮?
推荐答案
我继续进行了广泛的搜索,并找到了有关在Joomla 1.5的文章编辑器中添加其他按钮的指南.
I've continued my extensive search and have found a guide on adding an additional button to the Article Editor for Joomla 1.5.
由于XML清单标准已经稍有更改,因此开箱即用对于Joomla 2.5和Joomla 3.0而言是无法使用的.为了与本教程保持一致,请改用此XML清单.
Straight out of the box this won't work with Joomla 2.5 and Joomla 3.0 as the XML manifest standards have changed ever-so-slightly. Keeping in line with the tutorial use this XML manifest instead.
<?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教程是正确的,如下所示:
The tutorial PHP is correct and is as follows:
<?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;
}
}
?>
谢谢大家的帮助.如果您还有其他更好的方法,我将不胜感激.
Thank you all for your help. If you have any other better methods I'd be most grateful.
这篇关于将自定义按钮添加到Joomla的文章编辑器(TinyMCE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!