Jump to content

Different 'CKEditor Toolbar' options for the same field on different templates


a-ok
 Share

Recommended Posts

Just a little thing but I tend try and use as many 'global' fields as possible across my sites (global_text, global_textarea, global_file, global_files etc.) and when you add each to a different template you can change the title of the field for that template, which is great, but what would also be great is for, say textareas, you could amend what's in the CKEditor Toolbar for the same field but on different templates. Sometimes templates just need Bold and Italic whereas some others need a lot more and having to allow the client access to the 'maximum' number when it's not required gets a bit frustrating.

Anyway... just my thoughts!

Link to comment
Share on other sites

You can see the differences in the DB table `fieldgroups_fields` between the template changed field and the RepeaterMatrix changed field...

1615360103_ScreenShot2019-01-31at20_39_39.png.9af98175fbd60d040daadac417768dd5.png

893816590_ScreenShot2019-01-31at20_39_57.thumb.png.06456bc952e63bacf3b6e30557b4496a.png

The `fieldgroups_id` and `fields_id` are correct

334436879_ScreenShot2019-01-31at20_49_56.png.56dab3a9d6a85122649355bdf2360d5b.png

I wonder if it's just not built to work? Doesn't work with repeaters either.

Link to comment
Share on other sites

8 hours ago, a-ok said:

Ah this doesn't work with RepeaterMatrix fields

If you mean you want to have different toolbars for different matrix types that use the same CKEditor field then changing field settings in template context is not going to be a solution because all matrix types within a Repeater Matrix field use the same template.

And some hook that checks the matrix type is not going to be a solution either because there is only a single CKEditor configuration per CKEditor field that is sent to the ProcessWire.config JS object. So all instances of a CKEditor field on a page get the same config.

I think the only way to have different CKEditor configs for different matrix types is to use a different CKEditor field for each matrix type that needs a custom toolbar. If you want to use those CKEditor fields in different templates besides the Repeater Matrix template then you can use template context for overrides.

  • Like 1
Link to comment
Share on other sites

23 minutes ago, Robin S said:

If you mean you want to have different toolbars for different matrix types that use the same CKEditor field then changing field settings in template context is not going to be a solution because all matrix types within a Repeater Matrix field use the same template.

And some hook that checks the matrix type is not going to be a solution either because there is only a single CKEditor configuration per CKEditor field that is sent to the ProcessWire.config JS object. So all instances of a CKEditor field on a page get the same config.

I think the only way to have different CKEditor configs for different matrix types is to use a different CKEditor field for each matrix type that needs a custom toolbar. If you want to use those CKEditor fields in different templates besides the Repeater Matrix template then you can use template context for overrides.

This is all fair! Thanks for the explanation.

FYI it doesn't work for Repeaters either... but maybe that's a different thing.

Link to comment
Share on other sites

  • 6 months later...

Apologies to bring this back up but I'm curious to know why this doesn't work for standard repeaters? They use a separate template, for example 'repeater_about', so even if I change this by editing the template by showing the system templates it still doesn't work.

Considering repeater rows are 'pages' and use their own template... you would think it would work?

Link to comment
Share on other sites

13 hours ago, a-ok said:

Considering repeater rows are 'pages' and use their own template... you would think it would work?

I think it's a bug and I've opened an issue here: https://github.com/processwire/processwire-issues/issues/956

Regarding different CKEditor configs per Repeater Matrix type, Ryan has suggested some code in a recent topic in the ProFields forum:

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...