2013-03-04 56 views
0

我正在开发基于Joomla组件的小型Web应用程序(手机)。是否可以使用自定义文件中特定组件的方法?例如,现在要使用核心功能,如数据库我使用类似的东西:可能joomla模型没有控制器在不同的文件?

define('_JEXEC', 1); 
define('JPATH_BASE', dirname(__FILE__).'../'); 
define('DS', DIRECTORY_SEPARATOR); 

require_once(JPATH_BASE.DS.'includes'.DS.'defines.php'); 
require_once(JPATH_BASE.DS.'includes'.DS.'framework.php'); 

$mainframe = &JFactory::getApplication('site'); 
$mainframe->initialise(); 
$this->db = &JFactory::getDbo(); 
+0

你想创建使用joomla框架的独立应用程序吗?看看[如何使用Joomla!创建独立应用程序!平台](http://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla!_Platform) – 2013-03-04 10:21:53

+0

@MarkoD不完全。我需要在我的应用程序中使用当前组件的几个方法,这与joomla无关...... – Kin 2013-03-04 10:25:58

+0

您需要包含'require_once(JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory .php');'以及在根文件夹中有'config.php'文件。并失去'&',它会产生通知作为php 5.3+ – 2013-03-04 10:29:03

回答

0

请尝试使用以下内容。

define('_JEXEC', 1); 
define('JPATH_BASE', realpath(dirname(__FILE__))); 
require_once (JPATH_BASE .'/includes/defines.php'); 
require_once (JPATH_BASE .'/includes/framework.php'); 
require_once (JPATH_BASE .'/libraries/joomla/factory.php'); 

$db = JFactory::getDbo(); 
+0

我需要获取组件的模型 – Kin 2013-03-04 12:30:18

相关问题