2

This answer does almost have what I need.

But it's two years old and nothing in the links provided in the answer points to a solution for EE3.

I want another save / save + close button pair on top of the entry as I am editing very long entries with many fields.

Does anybody have a working solution for EE3?

Can I use i.e. the plugin Publish Bar which has been last updated in 2011? Did the EE plugin API change a lot since then?

I don't want to alter the backend code, as that would be a lot of work for each time I need to update EE3.

1 Answer 1

7

Well, this is very easy. You just need to call jQuery on a cp_js_end hook. Just copy and paste the code below.

Instructions:

  1. Access your EE install via FTP and go to the folder system/user/addons

  2. Create a folder inside addons folder and name it button_move

  3. Create a file inside it named addon.setup.php and paste this code inside it:

    <?php
    return array(
        'author' => 'Mufi',
        'author_url' => '#',
        'description' => 'Copy Channel entry submit button to TOP',
        'docs_url' => '#',
        'name' => 'Clone Channel entry Button to TOP',
        'settings_exist' => false,
        'version' => '1.0.0',
        'namespace'   => 'EllisLab\Addons\Button_move',
    );
    
  4. Create a file named ext.button_move.php and paste this code inside:

    <?php if (!defined('BASEPATH')) die('No direct script access allowed');
    class Button_move_ext
    {
        public $version         = "1.0.0";
        public $name            = 'Clone Channel entry Button to TOP';
        public $description     = 'Copy Channel entry submit button to TOP';
        public $docs_url        = '#';
        public $settings_exist  = FALSE;
        public $settings        = array();
        public $hook            = 'cp_js_end';
    
        public function __construct()
        {
            $this->EE =& get_instance();
            $this->site_id = $this->EE->config->item('site_id');
    
        }
    
        public function activate_extension()
        {
             $data = array( 'class'     =>  __CLASS__,
                            'method'    =>  "copy_btn",
                            'hook'      =>  $this->hook,
                            'settings'  =>  "",
                            'priority'  =>  100,
                            'version'   =>  $this->version,
                            'enabled'   =>  'y'
            );
            // insert in database
            $this->EE->db->insert('extensions', $data);
        }
    
        public function disable_extension()
        {
            $this->EE->db->where('class', __CLASS__);
            $this->EE->db->delete('extensions');
        }
    
        public function update_extension($current=FALSE)
        {
            if($current == $this->version) return false;
    
            // Update the extension
            $this->EE->db
                ->where('class', __CLASS__)
                ->update('extensions', array('version' => $this->version));
        }
    
        public function copy_btn()
        {
    
            $js = '';
            if ($this->EE->extensions->last_call !== FALSE)
            {
                $js = $this->EE->extensions->last_call;
            }
    
            $js .= "var url = document.URL;
                    var chk = url.search('/cp/publish/edit/entry');
                    if(url.search('/cp/publish/edit/entry') != -1 || (url.search('/cp/publish/create') != -1))
                    {
                        $(document).ready(function(){
                            $('ul.tabs').next('form').prepend($('ul.tabs').next('form').find('fieldset.form-ctrls').clone().removeClass('form-ctrls').addClass('top-btn').css('margin-bottom', '10px').css('text-align', 'center'));
                        });
                    }";
            return $js;
        }
    }
    ?>
    
  5. In Add-on Manager inside the CP install the plugin called Clone Channel entry Button to TOP.

All the publish entry/edit entry pages now have a button at the top as well as the original one at the bottom.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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