3

I'd like to show a listing of Playa child entries (child's title + a few custom fields), ordered by their total_parents (total number of parent entries associated with the child entry). The child entry with the most parents would be at the top of the list; the child entry with the fewest parents would be at the bottom.

I've looked through the Playa docs, EE StackExchange, and old P&T support site at Get Satisfaction. But I've had no luck so far. I suspect I've overlooked something obvious, or am off track in thinking about the problem.

I would really appreciate suggestions on how you would approach this issue. Thanks!

3

After some quick testing I'm pretty certain you can use the playa tag "total parents" and pipe that in as an orderby parameter. The playa children tag, as stated in their documentation "{exp:playa:parents} supports almost all of {exp:channel:entries}’ tag parameters", so it accepts orderby and sort parameters. So, the following should accomplish what your looking for:

 {exp:playa:children 
    channel="your_channel" 
    entry_id="1" 
    field="your_field" 
    orderby="{exp:playa:total_parents}"
 }
      {exp:playa:total_parents} - {title}
{/exp:playa:children}

I tested this using EE 2.6.1 and Playa 4.4.5. I included the {exp:playa:total_parents) so that in testing you could see if it is actually sorting based on the number of total parents. Also, if you want to perhaps reverse the order you could add another parameter of sort="asc"

Hope this helps and let me know if you run into any issues.

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.