如何将Joomla参数传递到iframe(包装器)页面? [英] How to pass Joomla parameters to an iframe (wrapper) page?

查看:91
本文介绍了如何将Joomla参数传递到iframe(包装器)页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用getUser()函数和位于Joomla的iframe(包装程序)中的php脚本来获取我的用户信息.似乎在将参数传递给iframe代码时出现问题.捕获用户信息的唯一方法是将代码插入基本文章(不是iframe)中.

I try to fetch my users information using the getUser() function with a php script located in a iframe (wrapper) of Joomla. It seems there is problem passing parameters to iframe code. The only way I can catch user informations is to insert the code into a basic article (which is not an iframe).

var_dump($ user);输出显示:

The var_dump($user); output shows :

object(JUser)#17 (23) { ["isRoot":protected]=> NULL ["id"]=> int(0) ["name"]=> NULL ["username"]=> NULL ["email"]=> NULL ["password"]=> NULL ["password_clear"]=> string(0) "" ["usertype"]=> NULL ["block"]=> NULL ["sendEmail"]=> int(0) ["registerDate"]=> NULL ["lastvisitDate"]=> NULL ["activation"]=> NULL ["params"]=> NULL ["groups"]=> array(0) { } ["guest"]=> int(1) ["_params":protected]=> object(JRegistry)#18 (1) { ["data":protected]=> object(stdClass)#19 (0) { } } ["_authGroups":protected]=> NULL ["_authLevels":protected]=> NULL ["_authActions":protected]=> NULL ["_errorMsg":protected]=> NULL ["_errors":protected]=> array(0) { } ["aid"]=> int(0) }

关于出什么问题的一些想法? 谢谢, 佛罗伦萨

Some idea of what is going wrong ? Thank you, Florent

<?php

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$user = JFactory::getUser();

echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is $user->username}</p>";
echo "<p>Your usertype is {$user->usertype} which has a group id of {$user->gid}.</p>";
//var_dump($user);
?>  

推荐答案

如前所述,当您使用包装器时,Joomla环境是未知的.因此,您需要在使用Joomla API之前将其嵌入.为此,只需复制并粘贴以下代码(或创建一个新的PHP文件并将其包含在您的自定义页面中):

As previously said, wchen you use a wrapper, the Joomla environment is unknown. So you need to embed this before using Joomla API. To do this, just copy and paste this code (or create a new PHP file and include it in your custom page) :

<?php
define('_JEXEC', 1 );
define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT'] ); 
define( 'DS','/' );

require_once ( JPATH_BASE.DS. 'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
require(JPATH_BASE.DS.'libraries/joomla/factory.php');

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
?>

这篇关于如何将Joomla参数传递到iframe(包装器)页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆