Web Hosting from Bluehost. Sign-up here

How to customise Redactor editor in Perch

Posted on by Clive Walker in Perch

Summary: Adding a View Source button to Redactor editor in Perch. Customising the editor using other Redactor plugins.

Perch 3.0 comes with several textarea editors (Redactor, Simple MDE, Markitup) installed by default. It's easy to create a Perch template to use your preferred editor (Redactor in my case). However, you might want to customise the editor, perhaps expanding what it can do by adding more buttons. So, this is what I did to add a View Source button (Redactor Source plugin) to the default Redactor editor in Perch. This can be used with other Redactor plugins too.

I followed the section "Custom configurations for default editors" on this page. Only this section. It's at the end of the page. That's different to the section before it where you are creating a new editor.

The "Custom configurations" section is how to configure the default editor.

  1. Add define('PERCH_CUSTOM_EDITOR_CONFIGS', true); to your overall Perch config file.
  2. Create a config.js file like the example on this page (amend as necessary) and put it in addons/plugins/editors/
  3. Download plugins you need from Redactor site, e.g https://imperavi.com/redactor/plugins/source/, and put these in /addons/plugins/editors/redactor-plugins
  4. Test on local dev site. Upload new files to live site.

That should be it.

Login to Perch and admire your new editor functionality :-)

Comments

  • Martin:

    19 Jun 2017 14:57:57

    Hi Clive
    Thanks for the post. I was just trying to build in the source plugin but I am not sure what to set as arguments, actually it doesn’t work.
    Here’s how I set the functions:

    var get = function(editor_config_value, redactor, textarea)
    var load = function(cb)

    Your help is much appreciated!

  • 20 Jun 2017 04:56:30

    I started with the exact same config.js file as the Perch documentation page and that worked for me. Have you tried that?

Leave a comment

A simple question that helps prevent automated form fillers.

© 2017 Clive Walker