I want to modify the content field of a resource in a plugin that listens to OnBeforeDocFormSave.
I haven’t had any luck getting a handle to the current contents of the field so I thought I’d just give up and ask.
-
☆ A M B ☆
- 24,524 Posts
The POST is always available in any of the "save" events. The document’s content would be $_POST[’ta’]. (I have no idea where that field name came from!)
Make sure you validate that before you use it!
Quote from: sottwell at Sep 06, 2009, 03:30 AM
The POST is always available in any of the "save" events. The document’s content would be $_POST[’ta’]. (I have no idea where that field name came from!)
Make sure you validate that before you use it!
That was one of the things I tried. Modifying it didn’t change anything in the DB on save.
Quote from: OpenGeek at Sep 06, 2009, 09:37 PM
In Revo, by the time this event is called, the actual content is stored in $_POST[’content’]. Before the event is called, this code is executed:
if (isset($_POST['ta'])) $_POST['content'] = $_POST['ta'];
That was one of the other things I tried (having seen that code). I’ll have to give it another try.
Ok, got it working. I had to stop using this:
$output = &$_POST['content'];
And do it the old-fashioned way:
$output = $_POST['content'];
// modify $output
$_POST['content'] = $output;
Thanks.
-
MODX Staff
- 10,725 Posts
It’s best not to make a copy of the variable to alter it; just work on the $_POST var directly. Otherwise, you are increasing the memory usage, and reducing the amount of content that can be handled based on your memory_limit.
Quote from: OpenGeek at Sep 07, 2009, 11:06 AM
It’s best not to make a copy of the variable to alter it; just work on the $_POST var directly. Otherwise, you are increasing the memory usage, and reducing the amount of content that can be handled based on your memory_limit.
Good point. That’s why I tried to use the reference variable.