Page 1 of 1

Call Lise instance in a page template as a content block

Posted: Thu Oct 28, 2021 4:41 pm
by pierrepercee
Hello,
I have an instance Lise that contains items (with fields like last name, first name, email, profession, department, etc.).

I would like a user (backend) editing a page to be able to select an item from this instance and then that displays details item view in the page.
In effect, this amounts to offering a choice via a drop-down list, then the choice made it must write

Code: Select all

 {LISEmycontacts action='detail' include_items = 'myselected-item-id'  template_detail='mydetailtemplate'} 
it's been three hours, my head hurts :)

Re: Call Lise instance in a page template as a content block

Posted: Thu Oct 28, 2021 5:22 pm
by velden
I'd consider http://dev.cmsmadesimple.org/projects/ecb2 using the dropdown from udt feature.

I quickly tested setup below.

Then a UDT to return the LISE items. I expect someone already made something

Sample UDT get_lise_items:

Code: Select all

$mod = cmsms()->GetModuleInstance('LISEmycontacts');
$parms['pagelimit'] = 1000;
$parms['showall'] = true;	// <- To disable time control queries
$item_query = new LISEItemQuery($mod, $parms);
$item_query->AppendTo(LISEQuery::VARTYPE_WHERE, 'A.active = 1');
$result = $item_query->Execute(true);
$items = array();
while ($result && $row = $result->FetchRow()) 
{
  $obj = $mod->InitiateItem(array("item_id","title"));
  LISEItemOperations::Load($mod, $obj, $row);
//  $items[$obj->title] = $obj->item_id; //only if item titles are unique and may need some proper escaping
  $items[$obj->alias] = $obj->item_id;
}
return $items;
In your page template:

Code: Select all

{content_module module="ECB2" field="dropdown_from_udt" block="test2" label="LISE instance" udt="get_lise_items" first_value="=select=" assign='liseitemid'}{$liseitemid=$liseitemid scope=global}
and

Code: Select all

{LISEmycontacts action=detail item=$liseitemid}

Re: Call Lise instance in a page template as a content block

Posted: Thu Oct 28, 2021 6:24 pm
by pierrepercee
Velden,

You save my week, really ! Many, many thanks !

The solution is very clever. I was miles away



It works perfectly ! Well done !

You like wine ?

Re: Call Lise instance in a page template as a content block

Posted: Fri Oct 29, 2021 11:06 am
by pierrepercee
Hello Velden,

Thanks to your help I was even able to display a detailed contact list in a LISE detail template.

To do this, all you have to do is add an element type field of a LISE instance. (select alias as identifier).
Then in the detail template:

Code: Select all

{elseif $fielddef.name == 'mycontactchoice'}
					{assign var=mychoicevalue=$fielddef.value scope=global}
{LISEcontactsmairie action=detail item=$mychoice template_detail=choicecontact}
I know, this must sound trivial to you, but for a simple integrator ...
You helped me a lot and I think your thread can interest many integrators, really ! :)