Call Lise instance in a page template as a content block

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pierrepercee
Forum Members
Forum Members
Posts: 148
Joined: Thu Jan 10, 2013 8:02 am

Call Lise instance in a page template as a content block

Post 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 :)
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

Post 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}
pierrepercee
Forum Members
Forum Members
Posts: 148
Joined: Thu Jan 10, 2013 8:02 am

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

Post 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 ?
pierrepercee
Forum Members
Forum Members
Posts: 148
Joined: Thu Jan 10, 2013 8:02 am

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

Post 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 ! :)
Post Reply

Return to “Modules/Add-Ons”