Page 1 of 1

Custom field of LISE entries in Khronos

Posted: Sun Apr 21, 2024 6:04 pm
by 10010110
Is there a way to have a custom select field of LISE entries in Khronos? I suppose this would be solved with the “dropdown from UDT” but how is this achieved?

Re: Custom field of LISE entries in Khronos

Posted: Thu Apr 25, 2024 12:19 pm
by 10010110
Just for the records, this is the solution:
Create a user defined tag.
Paste this code in:

Code: Select all

$mod = \cms_utils::get_module('LISE instance name here'); // put the name of the LISE instance here!!!

if( !is_object($mod) ) {
  /* probably handle errors */
  return;
}

$item_query = $mod->GetItemQuery($params);
$item_query->AppendTo(LISEQuery::VARTYPE_WHERE, 'A.active = 1');
$result = $item_query->Execute(true);

$items = [''];

while($result && $row = $result->FetchRow()) {

  $obj = $mod->LoadItemByIdentifier('item_id', $row['item_id']);
  $items[$row['item_id']] = $obj->title;
//  $totalcount = $item_query->TotalCount(); // overbodig?
}

if(isset($params['assign']) ) {
  $smarty->assign($params['assign'], $items);
}
else {
  return $items;
}
Create a custom field of type “dropdown from UDT” in Khronos settings and select this UDT. You should now see the LISE entries in a select field in the event edit screen.

Thanks velden and JoMorg. :)