modx-ace
modx-ace copied to clipboard
Recognizing Context settings
Ace does not allow different contexts to use other RTE, for example "web" uses TinyMCE, while "css" uses Ace. Romain Tripault of MODX gave me this solution:
Replace $modx->getOption('use_editor') by $modx->controller->context->getOption('use_editor') in the following lines and Ace should be able to handle context settings :
https://github.com/danyaPostfactum/modx-ace/blob/master/core/components/ace/elements/plugins/ace.plugin.php#L85 https://github.com/danyaPostfactum/modx-ace/blob/master/core/components/ace/elements/plugins/ace.plugin.php#L105
@sottwell would that also allow for User Setting overrides? I recall previously running into issues by trying to override "user_editor" on a per-user basis... curious if this is related?
I had wondered about the myself, but it seems to work. At least it did when I set a user setting. I can have the system setting set TinyMCE or a MarkItUp extra I have, a context setting use Ace (for CSS-type resources), and also have a user setting using a different RTE. I'm not sure about the user setting overriding the context setting for using Ace for the CSS resources, though. I was concerned about the web and other general contexts, while the CSS context is for a specific purpose that needs Ace or CodeMirror rather than an RTE like TinyMCE.
As far as I can tell, the context settings aren't automatically used to override system settings in this case because we are working in the mgr context, so the resource's context has to be explicitly specified.
Ok, I ran some tests, and it looks like with the changed code it doesn't allow a user setting to override. It probably would with code to explicitly look for a user setting, but I'm not sure how to do that.
I believe that adding $modx->user->getOption('use_editor') as part of the condition with an "or" clause will solve the problem. Or would it be $user->getOption('use_editor')?
$modx->controller->context->getOption('use_editor') || $modx->user->getOption('use_editor')
Not only context. It will be good to apply user and usergroup settings.