Page 1 of 1

LISE: getting alias from a second instance

Posted: Wed Aug 21, 2019 11:47 am
by antibart
Hi,

I have two LISE instances. 1. members, 2. workshops e.g.

Members is a list of persons, after click a lightbox shows some detailed information as biography etc.. It is used in a certain content page and within the LISE instance "workshops".

Workshops is a list of workshops. Every workshop has one or more different members.

With the field definition "LISE Instance item" editors are able to choose one or more certain members for the different workshops within the workshop instance.

Now I paste the team instance into the summery-template of the workshop instance.

It works - but as expected the whole team members list is displayed in every single workshop. But I only need the chosen.

My idea is now to catch the alias of the single member item and use it for the parameter include_items.

Code: Select all

{LISEmembers include_items=$item->alias_of_single_member_item}
But my problem: Field definition "LISE instance item" displays only the title of the the single items.

How can I catch the item aliases from the second instance?

Re: LISE: getting alias from a second instance

Posted: Wed Aug 21, 2019 12:16 pm
by Jo Morg
You should have chosen item_id or alias as the identifier when configuring the field definition. You can easily derive all other values from that but going back from title is not that simple.

[SOLVED]: LISE: getting alias from a second instance

Posted: Wed Aug 21, 2019 1:16 pm
by antibart
Thanks for your response.
Jo Morg wrote:You should have chosen item_id or alias as the identifier when configuring the field definition.
Yes I did.

It works now. It was another little error in the way I called the value.

I had to use

Code: Select all

{$item->fielddefs.members}
... which I did not.

Thanks a lot.

Re: LISE: getting alias from a second instance

Posted: Fri Aug 23, 2019 7:58 am
by antibart
Oops - I have another little problem.

I also have a search filter for "members" in my template. For this I need the title back. ::)

Don't now how to handle this. Would be thankful for any hint.

Summary:

To assign certain members of my members instance to a workshop I do this with alias as identifier:

Code: Select all

{LISELoader item='item' force_array=1 value=$item->fielddefs.members.value assign='items'}
{LISEMemebers template_summary='member' include_items=$item->fielddefs.members} 
It works fine.

To display readable and searchable filter options I need the title of the members items. "name_name" looks not that good and replacing/capitalizing characters will not be found.

I could easily make another custom field definition for the members. But it might be confusing for editors to choose members twice. So is there a way or any condition to call title AND alias?

Re: LISE: getting alias from a second instance

Posted: Fri Aug 23, 2019 10:30 am
by velden
Where does this 'assigning' all happen? In the frontend or in the backend?

Perhaps some screenshots could clarify it a little more?

Re: LISE: getting alias from a second instance

Posted: Fri Aug 23, 2019 12:36 pm
by antibart
Thanks for your interest.

The assigning itselfs happens in the backend in the LISE instance "LISEWorkshops". Editors should be allowed to assign some items of a second instance (LISEMembers) into an item of instance LISEWorkshops. But the assigned items are displayed in the frontend like this:

------------------------------------------------------------
10.08.2019
Workshop 1
Members: Jane Doe, Karen Doe
------------------------------------------------------------

In the item editor of "workshops" it looks like this:


Title
---------------------
Workshop 1
---------------------

Alias
---------------------
workshop_1
----------------------

custum url, description, date etc. as known...

then comes the field for the second instance items:

Instance
----------------------
LISEMembers
----------------------

Members

[ ] John Doe
[x] Jane Doe
[ ] Jim Doe
[x] Karen Doe
[ ] ...

The instance "LISEMembers" is a lightbox-gallery of people that must be edited seperately. They are not static.

Here is the reduced html-free code of the summary template of the instance LISEWorkshops, where everything happens. I put some comments in.

Code: Select all

{if $items|@count > 0}

<!-- Here is he search filter form. For this I need an item title instead of alias  -->

{LISEWorkshops action='search' filter='members'}

<!-- end search form -->  

        {foreach from=$items item=item}
   
<!-- Here I load the instance LISEMembers with 'alias' as identifier -->  
   
{LISELoader item='item' force_array=1 value=$item->fielddefs.members.value assign='items'}

<!-- end loading instance 'members' -->

<!-- here is the output of the instance 'members' -->

{LISEMembers template_summary='team' include_items=$item->fielddefs.members}

<!-- end output -->

        {/foreach}
{/if}
As you see: To display the assigned items of "LISEMembers" within a workshop I need the item aliases for the LISE parameter "include_items". Title won't work. If I do not use include_items, all members will be displayed.

But for the search filter I need a title. Otherwise I get this in the search form:

------------------
Options filter member:
john_doe
jane_doe
jim_doe
-------------------

Re: LISE: getting alias from a second instance

Posted: Fri Aug 23, 2019 2:03 pm
by velden
I'll post a LISE search template I once made for such a case.

Think it's a good example, but don't have a test-site now.

Code: Select all

{$actionid2=$actionid}
	{$formstart}
		{foreach from=$fielddefs item=fielddef}
		<div class="form-row">
		{if $fielddef.type != 'Categories'}
			<label for="filter_{$fielddef->alias}">{$fielddef->name}{if $fielddef->alias == 'artists'} <span class="spinner"><i class="fa fa-sync fa-spin"></i></span>{/if}</label>
			
			{if $fielddef.type == 'Checkbox'}
				<input type="checkbox" name="{$actionid2}search_{$fielddef->alias}" id="filter_{$fielddef->alias}" value="{$fielddef->value}" />
           				
			{elseif $fielddef->alias == 'artists'}
                 <input type="hidden" name="{$actionid2}search_{$fielddef->alias}" id="filter_artist_placeholder" >			
				 <input id="filter_artist" placeholder="Start typing Artist name (Requires 3 characters)">
			{else}
			
			{*** THIS IS RELEVANT ***}
			{$options = $fielddef->GetOptions()}
			<select name="{$actionid2}search_{$fielddef->alias}" id="filter_{$fielddef->alias}">
				<option value=''>{$mod->ModLang('all')}</option>
				{foreach from=$fielddef->values item=value}
				  <option value="{$value}">{$options[$value]|default:$value}</option>
				{/foreach}
			</select>
			{*** TILL HERE ***}
			{/if}
		
        {else}		
		  <label for="filter-category">{$fielddef->name}</label>
		  <select name="{$actionid2}category" id="filter-category">
          {LISEReleases action=category template_category=filter_options}
		  </select>
		{/if}
			
		</div>
		{/foreach}
	
		<input class="button search-button" name="submit" value="{$mod->ModLang('search')}" type="submit" />
	{$formend}

Re: LISE: getting alias from a second instance

Posted: Fri Aug 23, 2019 6:35 pm
by antibart
Thank you, velden.

I'm going to check on monday.

Re: LISE: getting alias from a second instance

Posted: Mon Aug 26, 2019 4:10 am
by antibart
Wow!

It works fine. Thank you so much. Relevant was only this short line:

Code: Select all

{$options[$value]|default:$value}
GREAT! :D