Different buttons for Redactor in Perch 3

  • OK, so in Perch 2 I used to be able to set size="s" (or m, etc) on the perch textarea field and then set the buttons shown on the Redactor editor accordingly. For example, in some instances I don't want the user to have access to all the buttons.


    So currently I have this in addons/plugins/editors/config.js:

    How can I specify different buttons and formatting, etc according to the size value I add to the textarea in the template? It was a really useful function to stop non-tech savvy editors from screwing things up!

  • drewm

    Approved the thread.
  • Hi,


    How can I specify different buttons and formatting, etc according to the size value I add to the textarea in the template?


    You would use the editor-config attribute for this.


    HTML
    1. <perch:content id="text" type="textarea" label="Text" editor="redactor" editor-config="minimal" html>


    You can access the value of the editor-config attribute in your custom configuration file:


    JavaScript
    1. var get = function(profile, config, field) {
    2. if(profile == 'minimal') {
    3. // hide some buttons
    4. config.buttonsHide = ['link', 'bold'];
    5. }
    6. return config;
    7. };