Hello Gez
Thanks for the link. I was able to use some of its info to connect to my J-Cook component. As you are aware, J-Cook uses a number of unique definitions which need to be declared in the external script before connection is seamless. I will share what I have found here to help others who may be looking for this type of info:
@define('COM_DEMO', 'com_demo');
@define('JPATH_ADMIN_DEMO', JPATH_ADMINISTRATOR . DS . 'components' . DS . COM_DEMO);
@define('JPATH_SITE_DEMO', JPATH_SITE . DS . 'components' . DS . COM_DEMO);
//Shortcut to include component libraries
if (!function_exists('cimport')){
function cimport($namespace, $option = 'com_demo', $className = null){
//Check if class already exists
if (($className) && class_exists($className))
return;
@require_once JPATH_ADMINISTRATOR .DS. 'components' .DS. $option . DS . str_replace(".", DS, $namespace) . '.php';
}
}
require_once(JPATH_ADMIN_DEMO .DS.'helpers'.DS.'helper.php');
JHTML::_("behavior.framework");
// Set the table directory
JTable::addIncludePath(JPATH_ADMIN_DEMO . DS . 'tables');
This allows the retrieval of data via:
JLoader::import( 'news', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_demo' . DS . 'models' );
$news = JModel::getInstance( 'news', 'DemoModel' );
$news->setState( 'title', $title );
$row = $news->getItems();
Save is also possible via
JLoader::import( 'newsitem', JPATH_COMPONENT_ADMINISTRATOR . DS . 'com_demo' . DS . 'models' );
$news = JModel::getInstance( 'newsitem', 'DemoModel' );
$news->save( $item );
My last issue is getting j-cook to return the ID of the newly inserted record.
I have tried insertid() without any success...
If you can shed any light on how to return the ID after insert it would be greatly appreciated. However, I will continue looking as well.
Thanks & regards
vlemos