Hi guys!
These advises didn't help me. Please let me know what I'm doing wrong. Here is the code:
$resource = $modx->getObject('modResource', $id);
function someFunc($tvname2decode) {
global $resource;
$object_from_tv = json_decode($resource->getTVvalue($tvname2decode)); // ← FAILS HERE
...
Tried also to pass $resource to function through function argument – failed. Tried to declare global $modx and then declare $resource within the function — failed... Seems like I'm missing some very simple but fundamental thing here...
Please help!
PS: I tried different combinations: problem is not in json_decode – simple $obj = $resource->getTVvalue fails too. And everything works fine when I process these TVs outside a function, but I need to repeat the process few times for different TVs, so using a function is a must.