PHPBB <!-- IF something here OR something here -->

问题描述 投票:0回答:3

我正在尝试在 PHPBB 中执行一个简单的 if 语句,但我无法弄清楚或找到在 if 语句中执行“或”的解决方案。 我已经找到了如何查明某个成员是否属于某个组的一部分,但现在我需要查明该用户是否属于该组或该组。

我已经尝试过了

<!-- IF S_GROUP_ID == 12 || S_GROUP_ID == 5 -->

我已经尝试过了

<!-- IF S_GROUP_ID == 12 or S_GROUP_ID == 5 -->

我是否遗漏了什么或者你不能在 IF 语句中执行 or 操作...?

html phpbb
3个回答
0
投票

经过尝试/错误我找到了解决方案

在includes/functions.php上我需要添加

if ( !function_exists('group_memberships') )
    {
        include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
    }
    $groups = group_memberships(false,$user->data['user_id']);
    foreach ($groups as $grouprec)
    {
        $template->assign_vars(array(
        'S_GROUP_' . $grouprec['group_id'] => true
        ));
    }

之前

//The following assigns all_common_variables that may be used at any point in a template.

在 .html 模板页面上我需要这样做:

<!-- IF S_GROUP_12 || S_GROUP_5 -->
...
<!-- ENDIF -->

0
投票
if ( !function_exists('group_memberships') )
{
    include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
}
$groups = group_memberships(false,$user->data['user_id']);
foreach ($groups as $grouprec)
{
    $template->assign_vars(array(
    'S_GROUP_' . $grouprec['group_id'] => true
    ));
}

使用此构造时,调试器会抛出错误:

[PHP Warning] Invalid argument supplied for foreach()

如何解决这个问题?


-1
投票

我会尝试:

<!-- IF S_GROUP_ID == 12 -->

<!-- ELSEIF  S_GROUP_ID == 5 -->


<!-- ELSE -->

<!-- ENDIF -->
© www.soinside.com 2019 - 2024. All rights reserved.