Spent few hours this morning wrestling with the {reverse_related_entries} tag. Couple of issues:
1. Content inside my {if no_reverse_related_entries}{/if} tag gets output – even if there are results to display. In other words, displaying my “no results” message along with each entry returned. Here’s my code (inside a channel entries tag):
<section id="reviews">
{reverse_related_entries
cache="yes"
channel="reviews"
orderby="date"
refresh="60"
sort="desc"
}
{if no_reverse_related_entries}<h3>There are no reviews available for this tour yet.</h3><p>{/if}<br />
<article class="review"><br />
{cf_review_body_en}<br />
<footer><br />
Posted by <strong>{title}</strong> on <time datetime="{entry_date format='{DATE_W3C}'}">{entry_date format="%F %j, %Y"}</time><br />
</footer><br />
</article><br />
{/reverse_related_entries}<br />
</section><!--/reviews-->2. Secondly, in a different area of the same template I need to output the total number of reverse related entries. If I use {total_results} I get the correct number, but it obviously loops – e.g. 4 4 4 4. So I’m trying with the Query mod instead, but that also loops in the same way:
{exp:query sql="SELECT rel_child_id FROM exp_relationships WHERE rel_child_id ='{my_entry_id}'"}
{total_results}
{/exp:query}Is it possible just to get a non-looping output from either {reverse_related_entries} or the Query mod?
My brain hurts :( Any help much appreciated.