如何扩展Joomla!到我的自定义PHP文件 [英] How to extend Joomla! to my custom PHP file

查看:107
本文介绍了如何扩展Joomla!到我的自定义PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建的php文件.我想扩展所有的Joomla!该文件的类.或者我至少希望能够使用Joomla的类来访问我的PHP文件中的数据库.如何以这种方式扩展功能?预先感谢.

I have a php file i created. I want to extend all the Joomla! classes to that file. Or i at least want to be able to use Joomla's class for accessing the database within my PHP file. How can I extend the functionality that way? Thanks in advance.

推荐答案

将这些行放在您的php文件顶部

put these lines on top of your php file

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/../../../../' );   // should point to joomla root
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();

现在您可以在此处使用所有的joomla类

now you can use all joomla classes here

这篇关于如何扩展Joomla!到我的自定义PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆