3

Can’t seem to find out how this is possible, but is there a way to compare and see differences between 2 stash set_list arrays?

For instance:

{exp:stash:set_list name="location_list" parse_tags="yes"}
 {exp:structure_entries depth="999" parent="8"}
  {stash:item_title}{title}{/stash:item_title}
  {stash:item_id}{entry_id}{/stash:item_id}
 {/exp:structure_entries}
{/exp:stash:set_list} 

and

{exp:stash:set_list name="checked_locations" parse_tags="yes"}
 {exp:channel:entries channel="checkins" author_id="{logged_in_member_id}" dynamic="no" }
  {stash:item_title}{title}{/stash:item_title}
  {stash:item_id}{entries_location}{entry_id}{/entries_location}{/stash:item_id}
 {/exp:channel:entries}
{/exp:stash:set_list} 

In the above, item_id returns the entry_id of a Playa field. So, would it be possible to compare these 2 lists and only output the ones that don’t have a match? It’s to create a drop down of the entries that don’t have an existing Playa relationship.

2 Answers 2

3

Reposting here the solution that I posted on Devot:ee to the same question:

<ul>
{exp:stash:get_list name="location_list"}
  {if  0 == {exp:stash:list_count name="checked_locations" match="#^{entry_id}$#" against="entry_id"}}
   <li>{entry_id}</li>
  {/if}
{/exp:stash:get_list} 
</ul> 
0
0

Not quite sure of the end goal but if youre looking to produce a list of entries for logged in author that don't have playa relationships.

I'd just use your 2nd list to capture all the users entries then use stash:get_list with match= and against= to spit out only items that match your criteria.

Using your set list above with the minor exception of just setting the relationship to a simple 'yes' as you don't need to set it if there is one present...

{exp:stash:set_list...}
...
{stash:item_id}{entries_location}{if entry_id}yes{/if} {if entry_id ==""}no{/if}{/entries_location}{/stash:item_id}
...
{/exp:stash:set_list}

{exp:stash:get_list name="checked_locations" match="#no#" against="item_id"}
... output items that don't have a relationship, set as no in the set_list
{/exp:stash:get_list}

This is all off-the-cuff and you'll have to fill in the blanks but by capturing it all in the exp channel loop and using the stash match tag you should be able to create a select list.

I've typed this up on my phone in transit so mind my simplicity pls :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.