LISE: getting alias from a second instance

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

LISE: getting alias from a second instance

Post 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?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1976
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE: getting alias from a second instance

Post 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.
"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!
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

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

Post 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.
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: getting alias from a second instance

Post 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?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: LISE: getting alias from a second instance

Post by velden »

Where does this 'assigning' all happen? In the frontend or in the backend?

Perhaps some screenshots could clarify it a little more?
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: getting alias from a second instance

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

Re: LISE: getting alias from a second instance

Post 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}
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: getting alias from a second instance

Post by antibart »

Thank you, velden.

I'm going to check on monday.
antibart
Power Poster
Power Poster
Posts: 1162
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: getting alias from a second instance

Post 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
Locked

Return to “Modules/Add-Ons”