Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Joomla菜单调用的php页面无法捕获登录的用户信息_Joomla - Fatal编程技术网

从Joomla菜单调用的php页面无法捕获登录的用户信息

从Joomla菜单调用的php页面无法捕获登录的用户信息,joomla,Joomla,我们有一个在Joomla运行的应用程序。有一个菜单选项,上面写着“我的数据”——点击它将在iframe中打开一个php页面。在这个目标php中,我们希望捕获当前登录用户的详细信息,这些信息是我们面临的问题 我们使用了JFactory::getUser(),但它没有显示任何内容。虽然如果将任何特定id作为参数传递给getuser,那么该id的详细信息就会出现。PFB代码。谁能帮帮我们吗。提前谢谢 /*******Start of code*********/ define('_JEXEC', 1

我们有一个在Joomla运行的应用程序。有一个菜单选项,上面写着“我的数据”——点击它将在iframe中打开一个php页面。在这个目标php中,我们希望捕获当前登录用户的详细信息,这些信息是我们面临的问题

我们使用了
JFactory::getUser()
,但它没有显示任何内容。虽然如果将任何特定id作为参数传递给getuser,那么该id的详细信息就会出现。PFB代码。谁能帮帮我们吗。提前谢谢

/*******Start of code*********/

define('_JEXEC', 1);

define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {

    include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {

    define('JPATH_BASE', dirname(__FILE__));

    require_once JPATH_BASE.'/includes/defines.php';

}

require_once JPATH_BASE.'/includes/framework.php';

$app = JFactory::getApplication('site');

$app->initialise();

$user =& JFactory::getUser();

echo 'User name: ' . $user->username . '<br />'; echo 'Real name: ' . $user->name . '<br />';

$specificuser =& JFactory::getUser(403);

echo 'Specific User name: ' . $specificuser->username . '<br />'; echo 'Specific Real name: ' . $specificuser->name . '<br />';

/******eof code********/
/*******代码的开头*********/
定义(1);
定义('DS',目录\分隔符);
if(file_存在(dirname(_file__)。'/defines.php')){
包含一个目录名(uuu文件_uuu)。'/defines.php';
}
如果(!已定义(“\u JDEFINES”)){
定义('JPATH_BASE',目录名(_文件__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
$app=JFactory::getApplication('site');
$app->initialise();
$user=&JFactory::getUser();
回显“用户名:”$用户->用户名。“
;回显“真实姓名:”$用户->名称。“
; $specificuser=&JFactory::getUser(403); 回显“特定用户名:”$具体用户->用户名。“
;回显“特定实名:”$具体用户->名称
; /******eof代码********/
与重新加载Joomla框架的方法不同,您可以只检查会话对象,这是调试模式下Joomla的转储:

Session
__default
    session.counter ⇒ 13
    session.timer.start ⇒ 1363124213
    session.timer.last ⇒ 1363162265
    session.timer.now ⇒ 1363162286
    session.client.browser ⇒ Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
    registry ⇒ {}
        user
            id ⇒ 0
            name ⇒
            username ⇒ 

尝试使用以下方法:

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' );
$mainframe = JFactory::getApplication('site');

$user = JFactory::getUser();

echo 'User name: ' . $user->username . '<br />'; 
echo 'Real name: ' . $user->name . '<br />';

$specificuser = JFactory::getUser(403);

echo 'Specific User name: ' . $specificuser->username . '<br />'; 
echo 'Specific Real name: ' . $specificuser->name . '<br />';
定义(1);
定义('JPATH_BASE',realpath(dirname(_文件));
require_once(JPATH_BASE.'/includes/defines.php');
require_once(JPATH_BASE.'/includes/framework.php');
require_once(JPATH_BASE.'/libraries/joomla/factory.php');
$mainframe=JFactory::getApplication('site');
$user=JFactory::getUser();
回显“用户名:”$用户->用户名。“
; 回显“真实姓名:”$用户->名称。“
; $specificuser=JFactory::getUser(403); 回显“特定用户名:”$具体用户->用户名。“
; 回显“特定实名:”$具体用户->名称

希望这有帮助

Hi-我刚刚在上面的代码$app=JFactory::getApplication('site')中注释了下面两行$应用->初始化();并将其替换为GetSession,它告诉我没有会话对象。这是否表明会话对象未被捕获到目标页面中?请尝试使用$\u session super变量或在此处阅读更多内容:其想法是在Joomla的背后执行此操作,因此您只需通过正常的php函数访问会话