0

I'm attempting to add a CKEditor plugin to Wygwam 4.0.9 in EE3, but the documentation I found in pixelandtonic and wygwam docs showing wrong upload folders.

There is no such folders as themes/third_party/ and system/expressionengine/third_party/ .

Please confirm the exact folder names where I will upload the PHP files.

1

In EE3 :

Theme third-party folder path is as follow:
themes/user/

System third-party folder path is as follow:
system/user/addons/

| improve this answer | |
0

I have uploaded smiley plugin to themes/user/smiley and created following ext.smiley.php and uploaded to system/user/addons/smiley, but the plugin is not appearing.

<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class smiley_ext
{
var $name           = 'smiley';
var $version        = '1.0';
var $description    = '';
var $docs_url       = 'http://ckeditor.com/';
var $settings_exist = 'n';

private $_hooks = array(
    'wygwam_config',
    'wygwam_tb_groups',
);

private static $_included_resources = FALSE;

public function activate_extension()
{
    foreach ($this->_hooks as $hook)
    {
        ee()->db->insert('extensions', array(
            'class'    => get_class($this),
            'method'   => $hook,
            'hook'     => $hook,
            'settings' => '',
            'priority' => 10,
            'version'  => $this->version,
            'enabled'  => 'y'
        ));
    }
}

public function update_extension($current = NULL)
{
    return FALSE;
}

public function disable_extension()
{
    ee()->db->where('class', get_class($this))->delete('extensions');
}


public function wygwam_config($config, $settings)
{
    if (($last_call = ee()->extensions->last_call) !== FALSE)
    {
        $config = $last_call;
    }

    // Check if our toolbar button has been added
    $include_btn = FALSE;

    foreach ($config['toolbar'] as $tbgroup)
    {
        if (in_array('MyPlugin', $tbgroup))
        {
            $include_btn = TRUE;
            break;
        }
    }

    if ($include_btn)
    {
        // Add our plugin to CKEditor
        if (!empty($config['extraPlugins']))
        {
            $config['extraPlugins'] .= ',';
        }

        $config['extraPlugins'] .= 'myplugin';

        $this->_include_resources();
    }

    return $config;
}

private function _include_resources()
{
    // Is this the first time we've been called?
    if (!self::$_included_resources)
    {
        // Tell CKEditor where to find our plugin
        $plugin_url = URL_THIRD_THEMES.'smiley/myplugin/';
        ee()->cp->add_to_foot('<script type="text/javascript">CKEDITOR.plugins.addExternal("myplugin", "'.$plugin_url.'");</script>');

        // Don't do that again
        self::$_included_resources = TRUE;
    }
}

public function wygwam_tb_groups($tb_groups)
{
    if (($last_call = ee()->extensions->last_call) !== FALSE)
    {
        $tb_groups = $last_call;
    }

    $tb_groups[] = array('MyPlugin');

    // Is this the toolbar editor?
    if (ee()->input->get('M') == 'show_module_cp')
    {
        // Give our toolbar button an icon
        $icon_url = URL_THIRD_THEMES.'smiley/myplugin/icons/smiley.png';
        ee()->cp->add_to_head('<style type="text/css">.cke_button__myplugin_icon { background-image: url('.$icon_url.'); }</style>');
    }

    return $tb_groups;
}

}
| improve this answer | |
  • Have you created addon.setup.php file ? It is required for ee3 addons. – Jainil Jun 3 '17 at 9:30
  • Also you need to replace myplugin with smiley. – Jainil Jun 3 '17 at 9:33
  • and the first letter of class name should be capital "Smiley_ext" – Mufi - Amici Infotech Jun 3 '17 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.