Share » Forums » Extensions » eZOE - Add a button calling a custom tag

eZOE - Add a button calling a custom tag

eZOE - Add a button calling a custom tag

Wednesday 14 April 2010 10:31:28 am - 5 replies

Author Message

Laurent Esposito

Wednesday 14 April 2010 10:36:44 am

In fact, I would like to imitate the button which call the "sub" or the "sup" custom tag

André R.

Friday 16 April 2010 3:58:11 am

sub and sup are native commands, and use native tags, you can't use that as your limited to what the xhtml parser in ezoe supports.

But it is possible to create custom commands that create a custom tag with a predefined name, take a look at how pagebreak is implemented, it's part of the ez theme, but could just as well have been in an TinyMCE plugin (and yes, that is how you should implement this).

The pagebreak pieces as an example (this button only inserts a tag, it does not work on/off like sub/sup does):

// Control name lookup, format: title, command
        controls : {
....
            pagebreak : ['pagebreak_desc', 'mcePageBreak'],
_mcePageBreak : function( ui, val )
        {
            var ed = this.editor, n = ed.selection.getNode();
            if ( n.nodeName === 'P' && n.parentNode.nodeName === 'BODY' )
                ed.execCommand('mceInsertRawHTML', false, '</p><div type="custom" class="pagebreak mceItemCustomTag"><p>pagebreak</p></div><p>');
            else if ( n.nodeName === 'BODY' )
                ed.execCommand ('mceInsertRawHTML', false, '<div type="custom" class="pagebreak mceItemCustomTag"><p>pagebreak</p></div>');
            else
                alert( 'Not a suported location for a pagebreak, place it in the root of your document!' );
        },

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Laurent Esposito

Friday 23 April 2010 3:17:23 am

Thank you very much. I will try it !

Best regards,

Laurent

Sebastiaan van der Vliet

Thursday 19 May 2011 2:21:41 am

Hi Community,

Has anybody had any success in turning a custom tag into a button? I would like to see an example...

Thanks,

Sebastiaan

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Sebastiaan van der Vliet

Thursday 19 May 2011 6:37:00 am

Well, that was actually easy. I will do a blogpost about it when i have some time.

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu