2

I've got an EE 2.6 site that has pages (no duh) as entries, and some of those pages have children (i.e. via a relationship field).

Now, what I'd like to do is generate a list of the pages that do not have parents. But I don't see any way to do this. I would prefer native related entries, but would be fine with using Playa... but it doesn't seem to offer this functionality either. Am I stuck with using a query?

Thanks!

0

2 Answers 2

2

You can use query module also like:

{exp:query sql="SELECT exp_channel_titles.entry_id, exp_channel_titles.title FROM exp_channel_titles LEFT JOIN exp_relationships ON exp_channel_titles.entry_id=exp_relationships.rel_child_id WHERE exp_relationships.rel_child_id IS NULL AND exp_channel_titles.channel_id=1 AND exp_channel_titles.status='open'"}

{entry_id} :: {title}

{/exp:query}

Check the WHERE condition having "channel_id" and "status", you can change according to your preference.

2
  • 1
    Hmm. Yes, this seems to do the trick. It's limited because it only shows entries that have NO children at all, not just in one the particular field/relationship that I want to check -- and I want to filter by category, too, so that's tricky! -- but this got me started and was a good answer to the question. Thank you. Commented May 3, 2013 at 20:07
  • @TravisSmith: glad to help you. :) Commented May 4, 2013 at 9:30
0

Travis -

Throw this into a blank template, replace the field name of course:

    <h2>pt_playa="IS_EMPTY"</h2>

{exp:channel:entries search:pt_playa="IS_EMPTY"}

{title}<br />

{/exp:channel:entries}

<hr />

<h2>pt_playa="not IS_EMPTY"</h2>

{exp:channel:entries search:pt_playa="not IS_EMPTY"}

{title}

{/exp:channel:entries}

You'll see that search can help you here, at least if I am understanding correctly :) But I think I may be reversed from what you want.

My testing was done with a Playa relationship field....

-Lisa P&T

2
  • I believe this shows entries with and without children, not with and without parents. Commented May 3, 2013 at 16:29
  • Yea, I was totally reversed. Sorry Travis :( What about Bhashkar's answer?
    – Lisa
    Commented May 3, 2013 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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