gpt4 book ai didi

php - 将自定义按钮添加到 Joomla 的文章编辑器 (TinyMCE)

转载 作者:可可西里 更新时间:2023-10-31 22:12:24 25 4
gpt4 key购买 nike

我试图在 Joomla 的文章编辑器中插入一个额外的按钮。它在扩展模式下使用默认的 TinyMCE 插件。如您所知,编辑器下方有 4 个按钮(文章、图像、分页符和阅读更多)。我想要做的是插入第 5 个按钮。 (我确实附上了一个图像按钮,所以说我不能发布,因为至少需要 10 个代表点数。)

我试过复制 Page Break Button 插件并重命名它等,然后将其作为新插件重新安装,但所有这些都会导致 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 list 标准已经发生了微小的变化。与教程保持一致,改用此 XML list 。

<?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;
}
}
?>

谢谢大家的帮助。如果您有任何其他更好的方法,我将不胜感激。

关于php - 将自定义按钮添加到 Joomla 的文章编辑器 (TinyMCE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13743561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com