Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: datahell on April 20, 2024, 21:39:24

Title: Elxis 5.5 and JSON parameters
Post by: datahell on April 20, 2024, 21:39:24
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.
Title: Re: Elxis 5.5 and JSON parameters
Post by: chongbing on April 27, 2024, 12:04:23

COOL ! 👍 I can feel that the new features will be highly anticipated. THANK YOU VERY MUCH!  datahell !
Title: Re: Elxis 5.5 and JSON parameters
Post by: datahell on May 06, 2024, 19:20:56
Elxis 5.5 will be available very soon. You can start the count down ;D