Not a big fan of modx, but sadly it's what we use in work.
I'm having trouble saving a modified template variable in modx evolution (1.0.5).
In my plugin, called with the OnBeforeDocFormSave event, I'm doing this to get and modify the tv:
//include global variables
global $content,$default_template,$tmplvars;
$foo = $tmplvars[$TV_ID][1] . "bar";
$tmplvars[$TV_ID][1] = $foo;
This doesn't appear to work. $foo is set but the tv isn't saved.
$TV_ID is the resource ID of the template variable I'm after.
There are numerous ways to get the TV with API calls, but how do I modify it before it's saved?
Any help appreciated.
This solution appears to work:
Called by the plugin on the OnBeforeDocFormSave event
//include global variables
global $content,$default_template,$tmplvars;
$foo = $tmplvars[$TV_ID][1] . "bar";
$tmplvars[$TV_ID][0] = $TV_ID; //added this line
$tmplvars[$TV_ID][1] = $foo;
where $TV_ID is the id of the Template Variable you are trying to modify.