User tests: Successful: Unsuccessful:
With the JDocument::addScriptOptions method it's possible to change script parameters like the TinyMCE plugin parameters from outside (like with a plugin). This functionality was implemented with the following PR: #3072 and in the TinyMCE here: #11157 (with examples)
The problem at the moment is, that the "new parameters" will only be merged on the first level, so for example for the TinyMCE you cannot change parameters of deeper level in an easy way.
Add the following code into your template index file:
$options = [
'foo' => [
'bar' => [
'bla' => 1,
],
'baz' => [
'blub' => 2
]
]
];
JFactory::getDocument()->addScriptOptions('Foobar', $options);
// Update the foo => bar => bla value
$options = [
'foo' => [
'bar' => [
'bla' => 2,
]
]
];
JFactory::getDocument()->addScriptOptions('Foobar', $options);
"Foobar": {
"foo": {
"bar": {
"bla": 2
},
"baz": {
"blub": 2
}
}
}
"Foobar": {
"foo": {
"bar": {
"bla": 2
}
}
}
This example is very small, but e.g. the tinyMCE has somewhere about 50 parameters with a level of 3 or more. If you want to change one parameter in the depth, you have to rebuild the whole tree (or load the current tree, setup the variables and then set again), which makes the "merge" a bit useless.
Perhaps @Fedik and @dgt41 could look over this functionality, because they worked with it.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
I have tested this item
I've tested this item successfully on a 3.6.8 installation, following the testing instructions.
looks fine
the "new parameters" will only be merged on the first level
that was intent
to keep stuff simple, and to force developer to use: getOptions() => modify an options array => setOptions(),
if it works, then can be as @bembelimen suggested also
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Ready to Commit after two successful tests.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-21 03:54:09 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
?
|
@bembelimen I like it and I don't see any problems changing the behaviour. Edge case if someone used this code to actually replace the values in the storage but then again I don't think that many people are actually using or even understand the
Joomla.storageOptions
. Anyhows I'm happy with this change but I guess @Fedik has the final say here!