ok - not sure what is going on here, my php kung-fu is pretty weak.
this used to work:
class ExtData extends xPDOSimpleObject {
function __construct(modX & $modx,array $config = array()) {
$this->modx =& $modx;
$config = array_merge(array(
'user' => $this->modx->getLoginUserID(),
'debug' => 'true',
),$config);
include_once('exthelpers.class.php');
$this->modx->addExtensionPackage('extdata',"[[++core_path]]components/extdata/model/");
$this->modx->lexicon->load('extdata:default');
$this->modx->log(modX::LOG_LEVEL_ERROR,'cons 5');
//$this->modx->setLogLevel(modX::LOG_LEVEL_DEBUG);
if(!$_SESSION['artist']){
$_SESSION['artist'] = 'newartist';
}
}
I called it from:
<?php
$classfile = dirname($modx->getOption('core_path')).'/core/components/extdata/controllers/extdata.class.php';
if (file_exists($classfile)) {
$output = include_once $classfile;
} else {
$modx->setLogTarget('ECHO');
$modx->log(modX::LOG_LEVEL_ERROR,'class not found at: '.$file);
}
$scriptproperties['queryData'] = (isset($queryData)) ? $queryData : "";
$scriptproperties['gigid'] = (isset($_POST['edit_gig'])) ? $_POST['edit_gig'] : "";
$scriptproperties['mp3id'] = (isset($_POST['edit_mp3'])) ? $_POST['edit_mp3'] : "";
$scriptproperties['discid'] = (isset($_GET['discid'])) ? $_GET['discid'] : "";
$scriptproperties['placeHolder'] = (isset($placeHolder)) ? $placeHolder : "";
if($_GET['edit_mp3']){
// we must be trying to edit an mp3!!
//echo 'editing an mp3!!';
$scriptproperties['queryData'] = 'GetOneMp3';
$scriptproperties['mp3id'] = $_GET['edit_mp3'];
}
/*
echo '<pre>';
print_r($scriptproperties);
echo '</pre>';
exit();
*/
if(class_exists('ExtraData') != true) {
$ExtraData = new ExtData($modx,$scriptproperties);
}
$output = $ExtraData->getData($scriptproperties,$hook);
return $output;
Now, I'm not sure what is happening or how to fix it - if I remove all the $this-> from the constructor it will at least get through that, but as soon as another function in the class gets called $this-> breaks it again. I'm thinking that $modx is not getting passed into the class properly?
any ideas?
this is the error:
Fatal error: Call to a member function getOption() on a non-object in /home/canad036/public_html/core/xpdo/om/xpdoobject.class.php on line 692
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525
Hey Sean did you ever figure out why you were getting that fatal error? I am having the same problem.
I think passing $modx as a reference variable may be necessary because lexicon->load() needs to modify the real MODX object, not a copy of it.
Also, since it's an xPDO object, it should be instantiated with $modx->newObject() rather than new().