0

I have one doubt in Joomla. I can able to get the user login details while I am accessing the index.php...Whereas if i created new folder named test and inside the folder i have created index.php and i have used below code in that case user details were not showing. Please help me on this

$user =& JFactory::getUser();

if (!$user->guest) {
  echo 'You are logged in as:<br />';
  echo 'User name: ' . $user->username . '<br />';
  echo 'Real name: ' . $user->name . '<br />';
  echo 'User ID  : ' . $user->id . '<br />';
}
4

2 回答 2

2

这应该足以加载框架,以便您可以使用 Joomla 类并访问用户对象:

<?php
define( '_JEXEC', 1 );
// JPATH_BASE should point to Joomla!'s root directory
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) );
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();
$user =& JFactory::getUser();
$session =& JFactory::getSession();
?>
于 2013-07-22T18:18:48.157 回答
0

据我了解,问题是您可以在其范围内访问 Joomla 功能。换句话说,如果您正在运行的页面中不包含框架,您将无法访问 Joomla 核心功能。

要访问 Joomla 之外的核心功能,请包含执行此操作的框架。请谷歌,看看它应该怎么做。

于 2013-07-22T08:57:06.277 回答