0

I need to do a 'component' this component uses Joomla! com_users to login and then connect a external db the use a form for sql updates.

In first time I install Joomla! and develop a custom component (not using fabrik because I cant do CroosDB JOINS) but i feel Im not doing the things the best way.

  1. I only use com_users for Joomla CMS
  2. I don't need any articles, modules, categories, templates, etc
  3. I don't need to install other any extensions
  4. I know how to connect a external db
  5. There is mandatory uses Joomla, Joomla CSM or Joomla Framework.

My app only uses com_users for login and then connect in other external db and execute CRUD on the external db.

My questions:

**Why i should use Joomla CMS if nothing (except com_users) is useful for me?

Can I use Joomla Framework and then "copy" com_users and use it?

I'm right when I say that my best option is to develop the "component" directly on Joomla Framework?**

I already install Joomla Framework (an hour ago) but i can't find enough documentation

Hope this question is for this section

BR

1
  • 1
    Is your app external to the Joomla installation? Are you using com_users just for user management? Then we don't write some super simple user management in plain PHP (there should be already a lot of free scripts on internet) and connect it to that external DB?
    – Adam M.
    Commented Aug 13, 2016 at 7:19

3 Answers 3

0

I haven't used joomla framework still now but if you need to connect diff. database with your joomla cms then following code may helps you;

<?php
//external db database connect from joomla cms
$option['driver'] = "mysql";
$option['host'] = "";//host
$option['user'] = "";//user
$option['password'] = "";//password
$option['database'] = "";//db
$option['prefix'] = "";//prefix
$external_db = & JDatabase::getInstance($option);

$external_db->setQuery("query");
$result = $external_db->loadObject();?>
1
  • i know how to connect a db on Joomla. The Joomla Frameworks uses JSON for do that. Commented Aug 13, 2016 at 21:48
0

For you the best option is to not use Joomla Framework as it is very difficult to find any decent documentation/tutorials and you won't get much help about it.

You have to use normal Joomla CMS package. If your app connects from outside of the app, then the solution is to use an external PHP script that uses Joomla's functionalities. If users can visit your webapp, simple login and execute a script that connect's to an external app and show some data, then the best solution is to just a use a simple module, not component as it would make it too complex for such a simple task.

In both cases functions would be similar (I will paste code for an external script, in other case just stripe what is not needed):

<?php
  define('_JEXEC', 1);
  define('JPATH_BASE', realpath(dirname(__FILE__)));

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

  $app = JFactory::getApplication('site');
  $jinput = $app->input;
  // $db = JFactory::getDbo(); This is simple local DB connect
  // And this is for external connection
  $option = array(); //prevent problems

  $option['driver']   = 'mysql';              // Database driver name
  $option['host']     = 'db.myhost.com';      // Database host name
  $option['user']     = 'mysqluser';          // User for database authentication
  $option['password'] = 'anduserspassword';   // Password for database authentication
  $option['database'] = 'nameofthedatabase';  // Database name
  $option['prefix']   = 'iypow_';             // Database prefix (may be empty)

  $db = JDatabaseDriver::getInstance($option);

  $user_login            = $jinput->getString('user_login', '');
  $user_password         = $jinput->getString('user_password', '');

  // use $app->login(array($user_login, $user_password)) to login user
  // https://api.joomla.org/cms-3/classes/JApplicationCms.html#method_login

  // if (user is logged in) {
    // then connect to an external DB

    // Simple query in Joomla's way
    // for more infomration how to fetch data see
    // https://docs.joomla.org/Selecting_data_using_JDatabase
    $query = $db->getQuery(true);
    $query
      ->select($db->quoteName('*'))
      ->from($db->quoteName('#__mytable'))
      ->where($db->quoteName('user') . ' = ' . $db->quote($user_login));
    $db->setQuery($query);
    $user = $db->loadObject();

    print_r($user);
  // }
?>
2
  • There is mandatory uses Joomla, Joomla CSM or Joomla Framework. My app only uses com_users for login and then connect in other external db and execute CRUD on the external db. I cant do this with a simple module. I need to use Jform / Jinput the best way is using a component. Commented Aug 13, 2016 at 21:51
  • I still can't understand well your project, but it seems to me that you can simple get it with an external script or module. If you want we can get in contact, talk and I can help you.
    – Adam M.
    Commented Aug 14, 2016 at 18:19
0

Before some research and ask on Joomla Framework google groups

I find, if you need to use com_users you will need to use the Joomla CMS. The framework is not an option you cannot run the users component in the framework.

If you do not with to drag along all the Joomla functionality for your solution you could consider using our Joomlatools Platform. (https://www.joomlatools.com/developer/platform/) The platform is a modern and slimmed down version of Joomla (based on 3.3 release). Fore more info see: https://www.joomlatools.com/developer/blog/2015/11/introducing-joomlatools-platform/

also check out our Joomlatools Vagrant Box for local Joomla development. Comes packed with tools to help you be more productive as a developer. You can find more info here: https://www.joomlatools.com/developer/tools/vagrant/

There is another option using Joomla Framework and if you are just using com_users just for user management Then we don't write some super simple user management in plain PHP (there should be already a lot of free scripts on internet) and connect it to that external DB (Thanks to Adam)

Using the framework I can use any other users solution package installing via composer.

Thanks for the answers I hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.