anderson Posted February 3, 2019 Share Posted February 3, 2019 Hi, I'm new, in every aspect. I want to boost CKEditor a little: add some extra button H1,H2,H3. (So, one step less than clicking "format" dropdown.) I've seen this thread: Customise CKEditor toolbar per role So I tried creating a /site/ready.php , inside which: $this->addHookBefore('Field(name=my_ckeditor_field)::getInputfield', function(HookEvent $event) { $field = $event->object; // Add extra buttons for superuser only if($this->user->isSuperuser()) $field->toolbar .= ', Table, TextColor, h3'; }); Apparently it's wrong, backend home page doesn't load any more, other backend pages have this text before header, and "h3" button doesn't show, and "table" and "textcolor", neither. Maybe this is a dumb question? Please help. Link to comment Share on other sites More sharing options...
Autofahrn Posted February 3, 2019 Share Posted February 3, 2019 Does your ready.php start with <?php namespace ProcessWire; And to have the H buttons you'll need some more code (maybe plugin) which can be triggered from the toolbar reference. Edit: https://ckeditor.com/cke4/addon/formatbuttons Link to comment Share on other sites More sharing options...
anderson Posted February 3, 2019 Author Share Posted February 3, 2019 2 hours ago, Autofahrn said: Does your ready.php start with <?php namespace ProcessWire; And to have the H buttons you'll need some more code (maybe plugin) which can be triggered from the toolbar reference. Edit: https://ckeditor.com/cke4/addon/formatbuttons Thank you very much! I'll try to learn about CKE addon. Now I add <?php namespace ProcessWire; but why "Table, TextColor" still don't show? Did I miss something else? Link to comment Share on other sites More sharing options...
anderson Posted February 3, 2019 Author Share Posted February 3, 2019 I put format-button folder under \site\modules\InputfieldCKEditor\plugins\ then: Edit field:body > Input > CKEditor Settings > plugins, I check "format-button", save. But still nothing happens. Link to comment Share on other sites More sharing options...
Autofahrn Posted February 3, 2019 Share Posted February 3, 2019 Is your CkEditor field indeed named "my_ckeditor_field"? If not, you'll need to edit your ready.php accordingly. Link to comment Share on other sites More sharing options...
anderson Posted February 4, 2019 Author Share Posted February 4, 2019 11 hours ago, Autofahrn said: Is your CkEditor field indeed named "my_ckeditor_field"? If not, you'll need to edit your ready.php accordingly. Thank you, my bad. Now I see Table and Textcolor. Link to comment Share on other sites More sharing options...
anderson Posted February 4, 2019 Author Share Posted February 4, 2019 15 hours ago, Autofahrn said: And to have the H buttons you'll need some more code (maybe plugin) which can be triggered from the toolbar reference. Now I got it, I have to add a line in CKEditor Toolbar, and must be lowercase. Link to comment Share on other sites More sharing options...
Autofahrn Posted February 4, 2019 Share Posted February 4, 2019 Glad you get it running. In the end its not that complicated, but the dependancies need to be understood first. I know.... And, yes, toolbar entries are case sensitive (no need for an additional line, you may place the buttons anywhere), and sometimes you'll need to read the code in plugin.js to find the string you have to put in. Link to comment Share on other sites More sharing options...
anderson Posted February 5, 2019 Author Share Posted February 5, 2019 15 hours ago, Autofahrn said: Glad you get it running. In the end its not that complicated, but the dependancies need to be understood first. I know.... And, yes, toolbar entries are case sensitive (no need for an additional line, you may place the buttons anywhere), and sometimes you'll need to read the code in plugin.js to find the string you have to put in. Thanks again, I appreciate it! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now