0

as the title says.. i need to get a all published nodes of type A that have been created and not used (at the moment) by other nodes.

in other words a list of all node of type A that are on the Database except for those that are NOT been referenced in an entity reference field.

the easy approach will be to load all nodes that uses node of type A, and that load all type A nodes and check for each if it's has a reference for it. but then if i add another node that will use node of type A as an entity reference i'll have to go back check it as well.

is there an easy way to do it ?

7
  • 2
    What does in use on other nodes mean? – Clive Jul 29 '13 at 13:24
  • How do I in your case define that a node has been used by another? Is it that they are referenced in a entity reference field? That they are linked to from the text in the body field? Etc. – Pontus Nilsson Jul 29 '13 at 13:25
  • sorry, i meant referenced in a entity reference field. – Gilad_Gr Jul 29 '13 at 13:32
  • 1
    Don't explain in comments, edit your question to clarify :) – Mołot Jul 29 '13 at 13:49
  • When you say "Never been used", does that mean if a reference has existed, and then been removed, should that count as "Have been before and thus should not show up in the list"? Does it have to be dynamic enough to search through all possible entity references, or would one specific field suffice? – Letharion Jul 29 '13 at 13:56
1

You could set up a view showing title of content type A, title of content type B (using relations), hide both and create a custom PHP field that just returns title of ct A if ct A does not have ct B referencing to it. Maybe

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.