1
Perhaps there is a much more elegant way? I needed this for myself and did not found a better solution. The following code is for XOOPS 2.0.17
1. edit class/theme.php and add after line 199 the following code:
'xoops_getgroups' => $xoopsUser->getGroups(),
2. in the template it looks like this:
<{if array_intersect('1', $xoops_getgroups)}>if user is in group 1, do anything<{/if}>
Addendum: Of course it is bad if you need an array and AFAIK there is no way to make an array INSIDE a template. You have to assign the array in the PHP-file to the template. Thanks to google I have found a function where you can build arrays inside a template.
1. save the following code as file function.assign_array.php in class/smarty:
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: assign_array
* Version: 1.0
* Author: Jens Lehmann
* Credits: Monte Ohrt
* Purpose: assign an array to a template variable
* Input: var = name of the array
* values = list of values (seperated by delimiter)
* delimiter = value delimiter, default is ","
*
* Examples: {assign_array var="foo" values="bar1,bar2"}
* {assign_array var="foo" values="bar1;bar2;bar3" delimiter=";"}
* -------------------------------------------------------------
*/
function smarty_function_assign_array($params, &$smarty)
{
extract($params);
if(empty($delimiter)) {
$delimiter = ',';
}
if (empty($var)) {
$smarty->trigger_error("assign_array: missing 'var' parameter");
return;
}
if (!in_array('values', array_keys($params))) {
$smarty->trigger_error("assign_array: missing 'values' parameter");
return;
}
$smarty->assign($var, explode($delimiter,$values) );
}
/* vim: set expandtab: */
?>
2. the template looks now like this:
<{assign_array var="gruppen" values="1,2"}><{if array_intersect($gruppen, $xoops_getgroups)}>if there is an intersection, do anything<{/if}>
It seems to be that other array-functions like in_array etc.pp. are working also with this code.
Enjoy trying.