0
votes

I have an EE site running EE 1.7. It is a magazine site that has monthly "Editions", each edition may or may not have a book review in it. On the site, I need to list the book reviews, in reverse chronological order by edition. Here's my code:

{exp:weblog:entries weblog="editions" orderby="edition-date" sort="desc" disable="categories|member_data|trackbacks" limit="10" paginate="bottom"}
 {reverse_related_entries weblog="book-reviews"}
  ....

My problem is that the pagination is working based on the editions weblog, thus paging through editions that do NOT contain any book reviews. Thoughts?

1
Have you tried using the search parameter to limit the editions to those where there is a related entry? expressionengine.com/legacy_docs/modules/weblog/… - AllInOne
The search parameter would work if she was showing Related Entries, but it won't work for Reverse Related Entries. - Derek Hogue
Do the entry dates of the book-reviews entries not correspond roughly to the "edition-date" field of the editions entries? Do they need to be grouped by edition? - Derek Hogue
Sadly, the entry dates of the book reviews are not meaningful, as much of this site was post-populated back to 2005 or so (in 2010). They do need to be grouped by edition, yes... - panzhuli

1 Answers

1
votes

A little tricky, you'll need to use an embed for this (or alternately you could create a small plugin to do this in a similar fashion).

Try this setup in your template. Replace the weblog_ids in the query with your own (in this example, 1 is editions and 2 is book-reviews).

{embed="embeds/reviews" entry_ids="{exp:query 
    sql="SELECT DISTINCT r.rel_child_id FROM exp_relationships r, exp_weblog_titles t  WHERE r.rel_parent_id  IN( SELECT entry_id  FROM exp_weblog_titles  WHERE weblog_id = 2 )  AND r.rel_child_id = t.entry_id  AND t.weblog_id = 1" 
    backspace="1"}{rel_child_id}|{/exp:query}"}

Then, in embeds/reviews:

{exp:weblog:entries weblog="editions" entry_id="{embed:entry_ids}" orderby="edition-date" sort="desc" disable="categories|member_data|trackbacks" limit="10" paginate="bottom"}
    {reverse_related_entries weblog="book-reviews"}
    ...