簡體   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