We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Rich Text Editor (RTE) Tools Development - Can’t get the example in the docs working

Development and Programming

Ben Parizek's avatar
Ben Parizek
128 posts
13 years ago
Ben Parizek's avatar Ben Parizek

Has anyone been able to extend the Rich Text Editor yet? I’d like to add a tool, but I can’t seem to get the example in the docs working.

I’ve noticed that when adding the globals() function, I also need to create a language file, but that doesn’t seem to be the problem. I’ve also noticed that the definition() function has a return value that opens and closes with a single quote and has a single quote variable in the WysiHat.addButton function within it. I changed some of those to double quotes but that didn’t help either.

I’ve placed the strip_tags folder in the third_party folder and it doesn’t appear anywhere. Where is it supposed to appear? I’ve checked the list for every different type of add-on and the list in the RTE Module Settings, but nothing is showing up anywhere. I can’t even get a die() statement in my RTE tool to kill the page.

My code is below. Any help would be wonderful. I’m comfortable troubleshooting once I start seeing errors but so far…

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

Class Strip_tags_rte {

    public $info = array(
        'name'        => 'Strip Tags',
        'version'     => '1.0',
        'description' => 'Strips all block and phrase-level formatting elements',
        'cp_only'     => 'n'
    );

    private $EE;

    /**
     *  Constructor
     */
    function __construct()
    {
        // Make a local reference of the ExpressionEngine super object
        $this->EE =& get_instance();
        
    }

    /**
     *  Globals we need defined
     */
    function globals()
    {
        $this->EE->lang->loadfile('strip_tags');
        return array(
            'rte.strip_tags.label' => lang('strip_tags')
        );
    }

    /**
     *  RTE tool Definition
     */
    function definition()
    {
        return "

        WysiHat.addButton('strip_tags', {
            label:         EE.rte.strip_tags.label,
            handler: function()
            {
                // Strip tags logic
                alert('dog');
            }
        });

        ";
    }
       
Stephen Callender's avatar
Stephen Callender
148 posts
13 years ago
Stephen Callender's avatar Stephen Callender

I faced the same problems when testing for a new tool as well, so I scraped it and just modified one of the core tools instead.

       
Ben Parizek's avatar
Ben Parizek
128 posts
13 years ago
Ben Parizek's avatar Ben Parizek

I should have mentioned, I also tried to just duplicate the default bold tool and rename the class and all the variables so it would basically do the same thing, but be named as if it was a third party tool. This did not work either.

       
Brian Litzinger's avatar
Brian Litzinger
704 posts
13 years ago
Brian Litzinger's avatar Brian Litzinger

I don’t know if you need all 3, but try adding an ext, mod, and upd file to the package with stubbed out/empty classes.

       
Jonathan Muth's avatar
Jonathan Muth
11 posts
13 years ago
Jonathan Muth's avatar Jonathan Muth

@litzinger

Thank you for your suggestion. Could you give us an example of what those stubbed out files would like? I have been trying to figure it out for the past 30 minutes and could not wrap my head around it. All I was able to produce were some PHP errors in the backend …

       
Ben Parizek's avatar
Ben Parizek
128 posts
13 years ago
Ben Parizek's avatar Ben Parizek

That helps get it installed.

I’ve discovered one more thing that is making this a confusing example too. It seems the RTE language file (/expressionengine/language/english/rte_lang.php) also has a line naming the Strip Tags field “Clear Formatting” (ln 78: ‘strip_tags_rte’ => ‘Clear Formatting’,) so no matter what you try to name your addon, it gets overwritten with this.

       
Ben Parizek's avatar
Ben Parizek
128 posts
13 years ago
Ben Parizek's avatar Ben Parizek

Jonathan, you can generate the skeleton for those files here: http://pkg.io/

Just call your extension and modules “strip_tags” and choose any extension hook as you won’t be using it.

       
Jonathan Muth's avatar
Jonathan Muth
11 posts
13 years ago
Jonathan Muth's avatar Jonathan Muth

I guess, today is not my day. I have generated those files but am not sure how to implement my rte_tool into the package. More PHP errors in the backend.

Could you maybe share/upload a working example module?

       
jbueler's avatar
jbueler
1 posts
12 years ago
jbueler's avatar jbueler

I know this topic is a little old, but I just ran across this issue and created a module for installing these RTE tools. https://github.com/jbueler/RTEToolManager thought it might help someone else out.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.