So basically I need to replace the URL's of my images OnBeforeDocSave in the main content and one of the TV's and I use the following code in a plugin to do so:
$template = $resource->get('template');
if($template == 48){
$newsletterContent = $resource->get('content');
$newUrlc = str_replace('src="assets/', 'src="http://www.mywebsite.com/assets/', $newsletterContent);
$newsletterContent = $resource->set('content', $newUrlc);
$newsletterSideBar = $resource->getTVValue('side_content');
$newUrls = str_replace('src="assets/', 'src="http://www.mywebsite.com/assets/', $newsletterSideBar);
$newsletterSideBar = $resource->setTVValue('side_content', $newUrls);
}
This however causes problems when triggered OnBeforeDocFormSave (the content bit works fine (the first 3 lines in the if statement) but when I add the code to replace the TV it gives me a weird error when I try to save...the error just comes out as a URL...not very helpful.)
I have another MODx install elsewhere which I use to develop and test stuff so I thought I'd try the same thing on that platform and got the same issue...so, while still in my dev environment I created two plugins. One for the content and one for the TV but the content plugin to get triggered OnBeforeDocFormSave (as I know it works already) and then the side content plugin to be triggered OnDocFormSave...and it worked! Sweet! Problem solved...
So I move everything over to my main website and replicate everything exactly (apart from the if($template == 48) obviously changed). The content plugin works (as it always did) but the side_content plugin does not...
What is going on here? Any ideas? The only difference in the 2 MODx installs is that my dev install is 2.2.6 and the main website is 2.2.4 (both revolution)
Any help would be greatly appreciated!
Thanks...
(If anything is unclear here just say and ill try write it a bit better haha)