繁体   English   中英

致命错误:在joomla 3.3中找不到类'JFactory'

[英]Fatal error: Class 'JFactory' not found in joomla 3.3

3我有一个我在我的网站上开发的表格但是没有joomla结构。 在表单上,​​我试图调用活动用户数据,如下所示:

$user = JFactory::getUser();
echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is  {$user->username}</p>";

但我得到:致命错误:第38行/home5/onlinepc/public_html/action/subs/custompcorder.php中找不到类'JFactory'

custompcorder.php是我创建的表单的名称,第38行是$ user = JFactory :: getUser(); 我的客人我必须在我的档案中加入一些东西吗?

您需要导入Joomla库才能使用它的API,如下所示:

<?php
    define('_JEXEC', 1);
    define('JPATH_BASE', realpath(dirname(__FILE__) . '/../../'));  
    require_once JPATH_BASE . '/includes/defines.php';
    require_once JPATH_BASE . '/includes/framework.php';

    $mainframe = JFactory::getApplication('site');
?>

您可能需要更改上面代码第2行的路径,具体取决于Joomla相对于自定义PHP文件的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM