在外部html页面中获取Joomla3用户数据


Get Joomla3 user data in external html page

我有一个joomla3网站,我建立了一个外部html页面,这是一个客户端应用程序(jquery),只对登录用户可见。该页面位于web服务器根目录下。

我将在这个html页面的顶部显示当前用户的数据。这可能吗?

我没有找到适合我这种情况的东西。JFactory在joomla3中似乎不存在

谢谢

您需要初始化整个框架以便访问它的各个部分。以主index.php为例,说明如何做到这一点。而不是路由和调度,把你的代码放在那里。

standalone-script.php

<?php
/**
 * Constant that is checked in included files to prevent direct access.
 */
define('_JEXEC', 1);
if (file_exists(__DIR__ . '/defines.php'))
{
    include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
    define('JPATH_BASE', __DIR__);
    require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
// Your code goes here...

据我所知存在https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/factory.php

看一下错误php,这可能会帮助你得到一个想法,如何使一个独立的页面。但是请注意,如果您需要从独立应用程序中提供平台,则需要确保指向正确的文件夹。