0

Is it possible with the playa field to pull through entries that aren't selected.

The idea is, I want to be able to pull through the entries that are selected and give them a tick icon, and then also pull through the entries that have been left out and give them a cross icon. So that I can easily display to the user what's included in a particular entry and what is not.

0

You could use the query module to select the entry IDs of all entries in that channel that are not in the playa and pass the IDs to the channel entries tag. Here's an (untested) example.

{exp:channel:entries dynamic="no" entry_id="{exp:query backspace='1' 
    sql='SELECT entry_id FROM `exp_channel_titles` 
    WHERE channel_id = 6 AND entry_id NOT IN 
    (SELECT `child_entry_id` FROM `exp_playa_relationships` 
    WHERE parent_entry_id=20229 AND parent_field_id = 28)'}{entry_id}|{/exp:query}"}
    {title}...
{/exp:channel:entries}

You will need to replace the channel_id (currently 6) with your channel id, the parent_field_id (currently 28) with the field ID of the playa field and the parent_entry_id (currently 20229) with the ID of the entry that has the playa field on it.

5
  • Please can you tell me which tables I will find those id's to replace, I can't get it to work and I think it might be because I'm using the wrong id's. May 19 '16 at 15:15
  • To get the channel id go to Admin>Channel Admin>Channels and you'll see the ID column on the table. To get Field ids go to Admin>Channel Admin>Channel Fields, click your field group and you'll see the IDs listed on the table. For the entry id go to Content>Edit>(your channel) and you'll see the IDs listed on the left in the table.
    – Patrick64
    May 20 '16 at 8:17
  • Thanks, the query works on it's own but just not when it is in the entry_id="" paramater on the channel entries tag. Do you know why? May 20 '16 at 9:35
  • It's probably a parse order problem. You might need to use an embed. Make a template (eg include/show_entries) with the code {exp:channel:entries dynamic="no" entry_id="{embed:entry_id}"}{title}{/exp:channel:entries} and then put this in your template: {embed="include/show_entries" entry_id="[exp:query goes here]" }
    – Patrick64
    May 20 '16 at 9:53
  • Also if you just want the title you can get that straight from the db like this:<ul>{exp:query sql='SELECT title as entry_title FROM exp_channel_titles WHERE channel_id = 6 AND entry_id NOT IN (SELECT child_entry_id FROM exp_playa_relationships WHERE parent_entry_id=20229 AND parent_field_id = 28)'}<li>{entry_title}</li> {/exp:query}</ul>
    – Patrick64
    May 20 '16 at 11:01

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.