0

I have a channel entries tag that displays one entry form the "markets" channel. Within that, I want to display article entries. The "articles"(parent) channel has a relationship field to select which "markets"(child) entry. But, I have other channels that also have a relationship field pointing to "markets" entries. So when I use the code below to display "parents" from a specific channel and field, it works fine. BUT, if that results in 3 entries being returned, the parents_total_results tag doesn't return 3, it returns a higher number. Is there any way to get a number of the entries returned from the parents tag?

{exp:channel:entries channel="markets" disable="categories|member_data|category_fields|pagination" sort="asc" limit="1" dynamic="yes" require_entry="yes"}
        {parents field="articlemarket" channel="articles" limit="3" sort="desc" orderby="date"}
        {parents:total_results}
        {/parents}
1

I'm wondering if it's a bug. As your results total is 8, are there actually 8 parent entries across channels/entries for this particular entry?

Try this code, should pull in all parent titles:

{parents}
{parents:title}<br>
{if parents:count == parents:total_results}
 Total: {parents:total_results}
{/if}
{/parents}
| improve this answer | |
  • Thanks for sticking with this with me! That code did display the titles of all the entries with a relationship field pointing to the market entry. It's displaying the 4 entries I want to display, as well as 4 more. So I guess this means parents:total_results either has a bug, or that is the expected outcome and it may need to be updated? – Mike Lohrman Mar 15 '19 at 15:44
  • FML, I figured it out. There is a {parents:total_results} tag outside of the parents tag higher up in the template. It was finding 8 and the the value wasn't changing for the next {parents:total_results} within the parents tag pair. So removed that and things are working ok now. – Mike Lohrman Mar 15 '19 at 16:06
0

Mike have you tried removing the field= parameter? you shouldn't really need it unless you're pulling data from multiple relationship fields in the articles channel.

{parents channel="articles" limit="3" sort="desc" orderby="date"}
{parents:total_results}
{/parents}
| improve this answer | |
  • Won't it pull any parent entries that have a relationship field pointed to the market entry though? I thought adding the field parameter prevented that from happening? – Mike Lohrman Mar 13 '19 at 2:54
  • Hard to guess without knowing the full channel structure, did you try it? – Bluedreamer Mar 14 '19 at 10:47
  • If I remove the limit from the parents tag pair, it's returning 4 entries like it is supposed to. But {parents:total_results} is still returning "8". if I remove the field parameter it doesn't seem to affect things one way or the other. – Mike Lohrman Mar 14 '19 at 15:02

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.