Text editors

Adding button to Atto toolbar at plugin installation

 
Picture of Gerhard Doppler
Adding button to Atto toolbar at plugin installation
 

Dear colleagues,
I wonder if it is possible to add a button to atto toolbar during the installation of an atto plugin.

I understand that it makes sense to let the administrator do this by using
Site Administration -> plugins -> Text Editors -> Atto HTML Editor -> Atto toolbar settings.

However it would be nice to add the new plugin-button directly to the toolbar, e.g. as last button.

Has anybody an idea how to solve this?

Thanks in advance and greetings,

Gerhard

 
Average of ratings: -
Picture of Eoin Campbell
Re: Adding button to Atto toolbar at plugin installation
Core developersParticularly helpful MoodlersPlugin developers

The Atto plugin for Wiris has code that does exactly what you want:

db/install.php

function xmldb_atto_wiris_install() {
    $toolbar = get_config('editor_atto', 'toolbar');
    if (strpos($toolbar, 'wiris') === false) {
        $groups = explode("\n", $toolbar);
        // Try to put wiris in math group
        $found = false;
        foreach ($groups as $i => $group) {
            $parts = explode('=', $group);
            if (trim($parts[0]) == 'math') {
                $groups[$i] = 'math = ' . trim($parts[1]) . ', wiris';
                $found = true;
            }
        }
        // Update config variable.
        $toolbar = implode("\n", $groups);
        set_config('toolbar', $toolbar, 'editor_atto');
}


 
Average of ratings: Useful (2)
Picture of Gerhard Doppler
Re: Adding button to Atto toolbar at plugin installation
 

Thank you very much - this approach works!

Best regards,

Gerhard

 
Average of ratings: -
Me!
Re: Adding button to Atto toolbar at plugin installation
Core developersMoodle HQParticularly helpful MoodlersPlugin developersTesters
You could add a db/install.php file to your plugin (search moodle for many examples) that reads the current config setting - appends to one of the lines and then re-saves the config setting.

 
Average of ratings: -