How to get component instance via code Joomla 1.7

282 views Asked by At

I want to use my Joomla 1.7 Components from a webservices placed inside the same server.

In other words, I have another file that will be used by mobile-apps to do stuff.

I'd like to use joomla core functions nor having to duplicate code nor having to make direct inserts in the DB bypassing joomla and formatting them to match "what Joomla would do".

For now I am able to get the DBO objects and make queries using joomla, but I want to use every component I need. For example,

<?php
    if (!defined('_JEXEC')) { define('_JEXEC', 1); }
    if (!defined('DS')) {  define('DS', DIRECTORY_SEPARATOR); }

    if (file_exists(dirname(dirname(__FILE__)) . '/defines.php')) 
    { 
        include_once dirname(dirname(__FILE__)) . '/defines.php'; 
    }

    if (!defined('_JDEFINES'))
    {
        define('JPATH_BASE', dirname(dirname(__FILE__)));
        require_once JPATH_BASE.'/includes/defines.php';
    }

    require_once JPATH_BASE.'/includes/framework.php';

    // Mark afterLoad in the profiler.
    JDEBUG ? $_PROFILER->mark('afterLoad') : null;
    $db = JFactory::getDocument()->getDBO();
    $query = $db->getQuery(true);
    $query->select('r.id');
    $query->from('#__asd as r');
    $query->join('LEFT', '#__xxx cc on cc.recipe_id = r.id');
    // Prepare where clause
    $query->where('r.published = 1');
    $query->group('r.id');
    $db->setQuery($query);
    $objectsList = $db->loadObjectList();
    $res = formatResult($objectsList);


function formatResult($obj)
{
    if($obj === NULL || !is_array($obj)){ return array('data' => 'Vuoto', 'code' => 0); }
    return array('data' => (array)$obj, 'code' => 1);
}
?>

EDIT: More specifically, I have installed (JFBconnect) and I want its functionality to login and register users from app.

0

There are 0 answers