简体   繁体   中英

How load extra plugins for Zend Dojo Form Element Editor?

I have simple Zend_Dojo_Form with Editor element, when I add aditional plugins I got notice from firebug

Cannot find plugin linkdialog

the code

class Some_Form extends Zend_Dojo_Form
{
    public function init() {
        $this->addElement('Editor', 'content', array(
            'label'=> 'Some editor title',

            'dijitParams' => array(
                'extraPlugins'=>array('linkdialog')
             ),
        );
    }
 }

How I can enable aditional plugins for Zend_Dojo_Form_Element_Editor? I tried to include manualy, but same results.

dojo.require("dijit._editor.plugins.LinkDialog");

any suggestions?

Thanks @Alan Kay, you got me on the right track, but to elaborate a little more.

There seems to be two categories of Dojo editor plugins, ' (built-in) plugins ' and ' extraPlugins '.

Here's a list of built-in plugins (unsure if it's up-to-date). You can add built-in plugins on Dojo enabled Zend Forms Elements fine:

$this->addElement('editor', 'summary', array(
    'label'              => 'Summary:',
    'plugins'            => array(
        // NOTE: specifying any will lose the default builtin plugins, 
        // so need to re-add the ones you want.
        // Builtin plugins
        'bold', 'italic', 'underline', '|',
        'insertOrderedList', 'insertUnorderedList', '|',
        'indent', 'outdent', '|',
        'justifyLeft', 'justifyRight', 'justifyCenter', 'justifyFull', '|',
        // dijit._editor.plugins that work
        'foreColor', 'hiliteColor', '|',            // TextColor
        'fontName', 'fontSize', 'formatBlock', '|', // FontChoice
        'createLink', 'insertImage', '|',           // LinkDialog
        'viewSource',                               // ViewSource
    )
));

Alternatively, there are two main libraries of extraPlugins, Dijit (http://dojotoolkit.org/reference-guide/dijit/_editor/plugins.html#dijit-editor-plugins) and Dojox (http://dojotoolkit.org/reference-guide/dojox/editor/plugins.html#dojox-editor-plugins). Unfortunately, 'extraPlugins' are unavailable in Zend Framework until the next minor release (1.12) ZF-11511 . You could use the patch to create your own library to extend Zend_Dojo_Form_Element_Editor in the meantime.

Note, when specifying 'extraPlugins', you want to use the 'short name' (eg 'createLink'), not the 'resource' (eg 'linkdialog'):

"The bolded text represents the resource; the basic text represents the "short name" to be added to the extraPlugins list." 'Using Plugins' (http://dojotoolkit.org/documentation/tutorials/1.6/editor/)

However, note in the above example, it's possible to include the 'short names' for some Dijit extraPlugin 'resources', but not Dojox to my knowledge. Unsure why this is (haven't looked into dojo src - anyone?). Try your luck.

I don't know if this will work for your exact syntax, but you don't want to set 'LinkDialog', you want 'createLink'. I'm guessing 'extraPlugins'=>array('createLink') is the change you need

I know the following works for me:

$this->addElement(new Zend_Dojo_Form_Element_Editor('content',
    array(
        'label' => 'Content:',
        'class' => 'soria',
        )
    )
);
$this->contents->addPlugins(array('|', 'createLink');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM