Say you have built a fantastic but ridiculously long list of properties for your plugin, snippet etc... and you want to import it in production site
You click the "Export" button and bam!
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.
Now you are panicking because this has always worked for you, and you have developed many a thing like this.
You google solutions to this error, they tell you to restart PHP ini, gini, and fini files ... some say a reboot, some say na.... impossible - server won't allow it.
You think Eureka - phpMyAdmin! You find the exact table, find say, your
plugin, and the
properties field ...
You see that the code in there is a little less than gibberish - JSON's sister from another mother.
You say oh well, lemme copy this exact thing to the other database in question - surely 'copy and paste' is panacea!
You refresh your production site and the plugin's properties now contain worse than rubbish ... jumbled garbage!
You scratch part of your head bald ...
Well, I finally wrote a snippet called "getDATpropsNOW" to export my stuff, thank you very much!
[[!getDATpropsNOW]]
$stress = $modx->getObject('modPlugin', array( 'name' => 'myInfamousPLUGIN' ));
$stress = $stress->get('properties');
$stress = json_encode($stress, JSON_PRETTY_PRINT);
$stress = str_replace(array('[[',']]','type'),array('&_#91;&_#91;','&_#93;&_#93;','xtype'),$stress);
//(remove underscore)
return "<pre>".$stress."</pre>";
Open a resource with a base template and call that snippet inside.
The result should be pretty pretty enough.
Copy it all and paste in a new file
myInfamousPLUGIN.js - then "IMPORT" that file in your production plugin.
This got all my required values- no complaint.
$stress = str_replace(array('[[',']]','type'),array('&_#91;&_#91;','&_#93;&_#93;','xtype'),$stress);
// (remove underscore) prevent any [[MODX tag]] from being parsed on the resource
// convert the word "type" to "xtype" so that there are no issues
If you have better ways of doing this please share for all of us to benefit.
Cheers,
- what is in a name?
[ed. note: donshakespeare last edited this post 8 years, 11 months ago.]