AndyB
Well-known member
In the following code example, my function is not returning the modified variable:
When I edit a post I should get the word "testing" added to the end of the message.
At this point the $newMessage variable is being passed into my function, but the variable $myData is not being passed back. What am I doing wrong?
Thank you.
PHP:
<?php
class Andy_ConvertImage_DataWriter extends XFCP_Andy_ConvertImage_DataWriter
{
public function preSave()
{
// make sure preSave() is only run once
if ($this->_preSaveCalled)
{
return;
}
// define variables
$newMessage = '';
$myData = '';
$newMessage = $this->get('message');
$this->mainLoop($newMessage);
$this->set('message', $myData);
// call parent function
parent::preSave();
}
public function mainLoop($newMessage)
{
$myData = $newMessage . 'testing';
return $myData;
}
}
?>
When I edit a post I should get the word "testing" added to the end of the message.
At this point the $newMessage variable is being passed into my function, but the variable $myData is not being passed back. What am I doing wrong?
Thank you.
Last edited: