I created custom tables and all the directories and XML, everything works, I include the following code :
$basePath = dirname(dirname(dirname(dirname(__FILE__))));
require_once $basePath . ’/config.core.php’;
require_once MODX_CORE_PATH . ’config/’ . MODX_CONFIG_KEY . ’.inc.php’;
require_once MODX_CORE_PATH.’model/modx/modx.class.php’;
$modx = new modX();
include_once(MODX_CORE_PATH.’components/custom/functions.php’);
$path = MODX_CORE_PATH . ’components/wishper_post/’;
$result = $modx->addPackage(’wishper_post’,$path.’model/’,’wishper_’);
I can query my new tables or Modx core table but when I try to save to modx Core table I get an error, this code:
$newMember = $modx->newObject(’modUser’);
$newMember->set(’username’,$_POST[’invite_email’]);
$newMember->set(’password’,md5($pass));
$newMember->save();
give this error:
Fatal error: Call to a member function get() on a non-object in /home/alaingab/public_html/core/model/modx/modx.class.php on line 1247
If I remove the code to include my custom package it works fine.
What am I doing wrong?
thanks
-
☆ A M B ☆
- 2,475 Posts
Which line is number 1247? Why do you need to create a new instance of the $modx object? Is this used in a Snippet? The $modx object should already be available.
Call to a member function get()...
This is failing on a get, not a set or save.
Use MODx, or the cat gets it!
I suspect that it’s because you’re using a new, uninitialized $modx object instead of the real one that’s already available. If you’re using this in snippet inside MODx, all of this code at the top is unnecessary:
$basePath = dirname(dirname(dirname(dirname(__FILE__))));
require_once $basePath . '/config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
If you’re using it outside of MODx, you need to add this:
$modx->initialize('mgr');