<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/mainpage' )); //mainpage is my joomla folder.
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['username'] = $user->get('name');
if ($user->get('guest') == 1) {echo"blabla";} else { echo "Hi ".$_SESSION['username']."! Welcome to our great website!";}
?>
这将导致浏览器中的blabla,我实际上想要'Hi“MyName”欢迎来到我们伟大的网站!'。我在 joomla 文件夹之外创建了这个文件。joomla 文件夹的名称是“主页”。$_SESSION['username'] 为空。我需要获取当前的 joomla 用户名或名称..
请帮忙...
谢谢,
狮子座