-3

我有PHP代码:

$uid = $xUS['id'];  // Current user id
$uname = $xUS['x_username'];          // Current user name
$ulink = '';  // Current user profile URL (leave blank for none)
$upic = $xUS['config_forum_avator_head'];                // Current user
$ismod = 0;                 // Is current user a moderator?
$sig = md5($uid . $uname . $ismod . 's79tvi40k95bs6mw');
$ssoParams = '&uid=' . $uid . "&uname=" .
urlencode($uname) . "&ulink=" .       urlencode($ulink) . "&upic=" . urlencode($upic) 
.   "&ismod=" . $ismod . "&sig=" . $sig;</i>

我的 Smarty 模板文件:

<iframe width='550' height='500' src='http://chatroll.com/embed/chat/pibux-chatroom?id=tgybumotNmY&platform=php{$ssoParams}&w=$0' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' allowtransparency='true'></iframe>

在这种情况下,{$ssoParams}变量返回一个空值。为什么?请帮忙。

4

1 回答 1

0

Read Smarty docs for example: http://www.smarty.net/docsv2/en/language.variables.tpl#language.assigned.variables

You need to assign a variable like:

$smarty = new Smarty();

$smarty->assign('ssoParams', $ssoParams); // assign(smarty var, PHP var); $smarty->display('template_file.tpl');

And of course you need to include smarty files, define templates etc.

For basic working example look example 2.9. here: http://www.smarty.net/docsv2/en/installing.smarty.basic.tpl#id2778275

于 2012-09-24T09:20:23.803 回答