Support > Elxis 4.x/5.x DEV

Elxis 5.5 and JSON parameters

(1/1)

datahell:
In the upcoming Elxis 5.5 the parameters of various extensions (modules, plugins, templates, etc) gets saved by default as JSON strings and not as newline separated text as up to Elxis 5.4. Elxis 5.5 is backwards compatible as it detects automatically the format of the string and you have no problem at all. However if in any third party extension you have developed you use to parse manually the parameters string you got from the database, you must check if the format is JSON or the old one before trying to parse the string. In this case post a reply below for instructions on how to parse the string.

Deference between Elxis 5.5 and previous versions

Elxis 4.x, 5.0-5.4 parameters string:
width=120\nheight=45\ncolour=red

Elxis 5.5+ JSON format (same parameters as above):
{"width":"120","height":"45","colour":"red"}

Elxis saveS automatically the parameters when you edit a module, a plugin, etc. But if you ever need to save them manually in your extension the use the new methon toJSONString. I will post an example with backwards compatibility, so the code below works on any Elxis version (for a sample module):

elxisLoader::loadFile('includes/libraries/elxis/parameters.class.php');

$modxml = ELXIS_PATH.'/modules/mod_mymodule/mymodule.xml';
if (isset($_POST['params'])) {
   $params = new elxisParameters('', $modxml , 'module');
   if (eFactory::getElxis()->getVersion() >= 5.5) {
      $row->parameters = $params->toJSONString($_POST['params']);
   } else {
      $row->parameters = $params->toString($_POST['params']);
   }
   unset($params);
} else {
   $row->parameters = null;
}


Note: Users will require to update all third party extensions that need update before updating to Elxis 5.5, because of Elxis 5.5 compatibility fixes. I have already released some updated extensions with Elxis 5.5 support.

chongbing:

COOL ! 👍 I can feel that the new features will be highly anticipated. THANK YOU VERY MUCH!  datahell !

datahell:
Elxis 5.5 will be available very soon. You can start the count down ;D

Navigation

[0] Message Index

Go to full version