2012-12-06 123 views
9

我想在Joomla的文章編輯器中插入一個額外的按鈕。它使用擴展模式下的默認TinyMCE插頭。正如你已經知道編輯器下有4個按鈕(文章,圖像,分頁符和閱讀更多)。我想要做的是插入第五個按鈕。 (我確實附加了一個圖像按鈕,所以我不能發佈至少需要10個重複點)。將自定義按鈕添加到Joomla的文章編輯器(TinyMCE)

我試着複製了分頁按鈕插件並重命名等,然後重新安裝它作爲一個新的插件,但所有這些都會導致TinyMCE出錯,並且不會出現任何按鈕。

問題:如何插入按鈕?

+0

你能發佈你的代碼嗎?我把它插入安裝,並在正確的地方,並啓​​用。 – Elin

+0

嗨艾琳,我認爲發佈的代碼,但它不會幫助,因爲它是默認的Joomla安裝附帶的'分頁符'按鈕已經可用的代碼。該插件已啓用,並處於與其他editor-xtd插件相同的位置。 –

+0

如果它完全是一個副本,那麼很可能無法更改某個名稱必須與xml中的某個內容匹配的地方。 – Elin

回答

7

我繼續我的廣泛搜索,並找到了向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; 
    } 
} 
?> 

感謝大家的幫助。如果你有其他更好的方法,我會非常感激。

+1

幸好你把代碼放在這裏,因爲教程鏈接現在不工作。 –

4

如果成功安裝插件,那麼你必須把你的插件名稱進入高級參數設置的 Custom pluginCustom buttontinymce plugins.And確保您已安裝的插件是published.See低於例如圖像。

這是設置enabled.see這個圖片我的自定義插件: enter image description here

然後在tinymce插件去先進的參數,並在最後看看到底有自定義字段option.see這一形象:

enter image description here

輸入插件名稱和按鈕name.And在文章管理器編輯器找到您的按鈕。

+1

只有當你想添加一個tinymce按鈕時,如果你想添加一個按鈕,下面是一個編輯器 - xtd插件。 – Elin

+0

感謝龍捲風。這是添加一個自定義圖標按鈕到工具欄的理想選擇,但我希望有一個更大的「閱讀更多」按鈕。感謝您使用圖形,它非常有幫助! +1使用圖像。 –

相關問題