I have a field in LISE set to the type "MAMS Groups Multi Select", where I can choose which MAMS groups should have access to a LISE item.
But the output from the field is a comma separated list of MAMS group IDs.
How do I get it translated to group names so it can be used in {mams_smarty::is_user_memberof($groups[,$uid])}?
Using LISE MAMS Groups Multi Select Topic is solved
Re: Using LISE MAMS Groups Multi Select
I didn't test it but an UDT like this:Then in your template, assuming you named the UDT 'ConvertGIDS2Names', something like:
Disclaimer: didn't test it so might not work out of the box, but the gist is there...
Code: Select all
$gids = $params['gids'] ?? [];
$out = '';
$assign = $params['assign'] ?? 'groups';
if(!is_array($gids) && FALSE !== strpos($gids, ','))
{
$gids = explode(',', $gids);
}
$mams = cms_utils::get_module('MAMS');
if( is_object($mams) )
{
$g_alias = [];
foreach($gids as $gid)
{
$tmp = $mams->GetGroupInfo($gid);
$g_alias[] = $tmp['groupname'];
}
$out = implode(',', $g_alias);
}
if($assign)
{
cms_utils::get_smarty()->assign($assign, $out);
}
return $out;
Code: Select all
{ConvertGIDS2Names}
{mams_smarty::is_user_memberof($groups}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Using LISE MAMS Groups Multi Select
Now I have had time to test and the UDT just works perfectly "Out of the box". Thank you very much!
It was more complicated to retrieve the MAMS group names than I first thought. And the solution was not at all within my thinking, how to solve it.
Just out of curiosity, what is the original thought behind "MAMS Groups Multi Select" and how the field and output should be used?
It was more complicated to retrieve the MAMS group names than I first thought. And the solution was not at all within my thinking, how to solve it.
Just out of curiosity, what is the original thought behind "MAMS Groups Multi Select" and how the field and output should be used?
Re: Using LISE MAMS Groups Multi Select
Fo reference if others can use it:
In my LISE Instance i've setup a field named "MAMS Groups" of type "MAMS Groups Multi Select".
Using Jo Morg's UDT "ConvertGIDS2Names" in my LISE Summary template:
In my LISE Instance i've setup a field named "MAMS Groups" of type "MAMS Groups Multi Select".
Using Jo Morg's UDT "ConvertGIDS2Names" in my LISE Summary template:
Code: Select all
{foreach from=$items item=item}
{if !empty($item->mams_groups) && mams_smarty::is_user_memberof("{ConvertGIDS2Names gids=$item->mams_groups}") || empty($item->mams_groups)}
Content
{/if}
{/foreach}
Re: Using LISE MAMS Groups Multi Select
To be perfectly honest, I believe that one is just a fork of an existing FEU one, but can't remember whether that's just it. I know that the users versions of the fields for FEU and then their adaptation to MAMS were bespoke and sponsored and have a lot more versatility. I'll add the features as possible to the other custom field too, while the FEU custom fields will be removed in a near future anyway. I'll venture saying that a better implementation of "MAMS Groups Multi Select" will make its configuration and use easier and more intuitive, so expect that soon.webform wrote: ↑Sun Jun 23, 2024 10:50 am Now I have had time to test and the UDT just works perfectly "Out of the box". Thank you very much!
It was more complicated to retrieve the MAMS group names than I first thought. And the solution was not at all within my thinking, how to solve it.
Just out of curiosity, what is the original thought behind "MAMS Groups Multi Select" and how the field and output should be used?
I'm glad the UDT actually worked as expected.

Cheers!
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!