We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4018
    • 1,131 Posts
    One of the neat features of FCKEditor is the ability to assign your own custom toolbar set. The question to ask is, "Why would I want to have a custom toolbar set?" After all, to most users the basic, standard, and advanced toolbar sets offer plenty, right? Well, some users may prefer to hide just one or two items from a specific set. Or a user may prefer to have the buttons in a particular order. A custom toolbar set allows you to do this and it’s relatively easy to do once you understand how button assignments work in FCKEditor.

    To get an idea on how toolbars work in FCKEditor, it’s good to look at how the existing default toolbars are assigned. In the folder for the FCKEditor plugin (located at assets/plugins/fckeditor) there’s a file called custom_config.js. In this file are sections for the basic, standard and advanced toolbars. Let’s look at the basic one first since it’s the easiest one to understand. The line should look like this:

    ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','Image']


    The whole section is one block of buttons with each button name in single quotes separated by commas and enclosed by brackets. A separator can be used by adding a dash in single quotes. The above button block has two separators. If you plan on having quite a few buttons, it’s recommended that you create multiple blocks for the purpose of allowing FCKEditor to span blocks of buttons for times when the width is relatively small. One large block of buttons will cause FCKEditor to not show some buttons. For example, take a look at the following block:

    ['Bold','Italic','Underline','-','Link','Anchor','-','Image','Flash','Table','Rule','SpecialChar','-','Style','FontFormat','FontName','FontSize','-','TextColor','BGColor']


    This is quite a few buttons for just one block. The result of this block will be that most of the buttons on the right of the toolbar will not show up and the toolbar will be cutoff. To alleviate this, simply create multiple blocks with brackets separated by commas like this:

    ['Bold','Italic','Underline'],['Link','Anchor'],['Image','Flash','Table','Rule','SpecialChar'],['Style'],['FontFormat'],['FontName'],['FontSize'],['TextColor','BGColor']


    You’ll notice that I purposely made the Style, FontFormat, FontName, and FontSize buttons as separate blocks. The reason for this is because these particular buttons are actually dropdown menus and can sometimes be cutoff if they are grouped together. As separate blocks, FCKEditor will span a block to a new row should they not fit the width of the editor.

    Take a look at both the standard and the advanced toolbar instances in the custom_config.js file to get an idea on how the existing toolbars are setup. With these, you should be able to easily create your own toolbar by rearranging the button names, blocks, and such to fit your needs.

    To add a custom toolbar set, simply navigate to System Configuration / Interface & editor settings page. In the FCKEditor Settings section, select ’Custom’ from the Toolbar Set dropdown box. A new text field labeled ’Custom toolbar’ will appear just below. Here, you can enter or paste in your own toolbar settings using the same methods as described above. Should you have any questions, feel free to post them here!

    Happy coding! smiley

    Jeff
      Jeff Whitfield

      "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
      • 18397
      • 3,250 Posts
      Great tip for those new to FCKeditor!

      Nice work Jeff!
      • Thank you sir, indeed.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 33337
          • 3,975 Posts
          Really usefull !

          Thanks for sharing great tip smiley

          regards,

          zi
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • Jeff, how do we control the appearance of the RTEs in the Rich Text Widgets for custom front end applications? Seems too want to just default to the basic toolbar.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 4018
              • 1,131 Posts
              You can change the toolbar by going to Manage Resources/Plugins/FCKEditor then click on the Configuration tab. There you can change the Web Toolbar in the same manner as you assign a Custom Toolbar from the System Configuration.

                Jeff Whitfield

                "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
              • Thanks! Could not for the life of me remeber where the heck that was!
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • OK Jeff... for the next question wink

                  Where would one go about customizing the style menu? (the one with custom bold, custom italic, code (orange/outlined), etc.)?
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • And a major bug:

                    The custom web toolbar config chops off anything after 227 characters. For example, this:
                    ['Preview'],['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Bold','Italic','Underline'],['OrderedList','UnorderedList','-','Outdent','Indent'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],['Image','Table','Rule','SpecialChar','PageBreak','UniversalKey'],'/',['Style'],['FontFormat'],['FontName'],['FontSize']
                    

                    Gets truncated to this:
                    ['Source','DocProps','-','NewPage','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Bold','Italic','Underli
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 13577
                      • 302 Posts
                      I’m just noticing (now that I have time to look at such things) that on my copy of 0.9.1 - the custom setting doesn’t appear to work. It just shows Bold, Italic, Underline, Link, and Unlink. No matter what I type in. If I hard code my custom toolbar into the custom_config.js file, I have no problems:

                      // custom
                      // Original bit:
                      // FCKConfig.ToolbarSets["custom"] = parent.FCKCustomToolbarSet;
                      // End original bit
                      FCKConfig.ToolbarSets["custom"] = [
                          ['Source','FontFormat','Bold','Italic','-','Subscript','Superscript'],
                          ['OrderedList','UnorderedList'],
                          ['Rule','Image','Link','Unlink']
                      ];

                      Anyone else experience this? Or is this another case of funky Jared unique issue blues??

                      Looking at the siteCache.idx.php file, I see that what I’m getting is the "default" custom menu. So for some reason... the custom set I declare isn’t getting picked up. Could this simply be a matter of needing to "refresh the site"...? (Tries that...) Nope.

                      // ... from siteCache.idx.php
                      $tbCustomset = isset($fck_editor_toolbar_customset) ? htmlspecialchars($fck_editor_toolbar_customset) : "[\'Bold\',\'Italic\',\'Underline\',\'-\',\'Link\',\'Unlink\']";
                        Standard Disclaimer
                        I could be totally wrong.