Reverse Entries by category solution
Posted: 25 February 2008 08:16 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  182
Joined  12-13-2007

I found myself today wanting to sort my reverse_related_entries by category, and was surprised when I couldn’t seem to do it.

I first tried to manually limit with the category id parameter, which had no effect:

{exp:weblog:entries weblog="schools"}
  {reverse_related_entries weblog
="faqs" catgegory="5"}                
      {if count
== 1}
          
<ul>
      
{/if}
      
<li><a href="#{url_title}"}>{title}</a>
      </
li>
      
{if count == total_results}
      
</ul>
      
{/if}
  {
/reverse_related_entries}
{
/exp:weblog:entries}

My only other thought was to do a category archive, but couldn’t figure out how to do it with only my related entries.

There’s gotta be a way to do this, right?

 Signature 

Fusionary | Geniuscar

Profile
 
 
Posted: 25 February 2008 08:26 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Right- if you double check the docs, category isn’t an available parameter.  And you can’t order by category in weblog tags normally- in part because entries can be assigned to more than one category.

Aside from going at it with a query- which I would only do on a single entry page- you could try Mr. Wilson’s Sortee- I can’t swear it works inside the reverse relationship tag- but it is meant to handle complex sorting.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 02 June 2008 06:47 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  61
Joined  01-23-2006

Does anyone know whether sortee can do what timkelty is asking? Or whether another way has been found?  I really need to be able to limit the reverse_related_entries by category!

 Signature 

Vibe9 Design - Vancouver Web Design Company

Profile
 
 
Posted: 03 June 2008 10:28 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

No, I haven’t really played with it.  Best answer on sortee would probably be found posting to the thread on it.  But to do it natively, you really need a feature request.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 June 2008 10:30 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  61
Joined  01-23-2006

Yeah, just checked sortee, does not look like it.
Heading to feature request now (totally surprised this isn’t one already).

 Signature 

Vibe9 Design - Vancouver Web Design Company

Profile
 
 
Posted: 03 June 2008 10:40 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  61
Joined  01-23-2006

Addendum, I have found a solution which seems to be working for me:

Here’s the related entry code:

{exp:weblog:entries weblog="my_weblog"}
{reverse_related_entries weblog
="myother_weblog"}
{embed
="globals/.album_item" pass_entry_id="{entry_id}"}
{
/reverse_related_entries}
{
/exp:weblog:entries}

Now here’s the embedded template that takes care of the category filter:

{exp:weblog:entries weblog="myother_weblog" category="5" dynamic="off" entry_id="{embed:pass_entry_id}"}
{title} {your_custom_fields}
{
/exp:weblog:entries}

Would still be nice if this were a feature though, to reduce the need for these extra queries and templates!

 Signature 

Vibe9 Design - Vancouver Web Design Company

Profile
 
 
Posted: 03 June 2008 03:42 PM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12434
Joined  04-29-2002

vibe9, does this work enough for us to close the post? You might want to make a FR if you haven’t done so already.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 03 June 2008 03:45 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  61
Joined  01-23-2006

Yes, it works well for me.
I will put in an FR as soon as time allows!

 Signature 

Vibe9 Design - Vancouver Web Design Company

Profile
 
 
Posted: 04 June 2008 07:13 AM   [ Ignore ]   [ # 8 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Yep- would make a good FR.  And just to note- this could get fairly resource intensive if there are a lot of related entries to loop through.  It’s running a weblog tag for each one- so while it may be fine in certain situations, keep an eye on it.  Could slow things down.

Closing this one out.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 02 July 2008 01:47 PM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-06-2008

Merged by Moderator

Too bad I can’t update the above thread directly. Anyway, I enhanced the solution that should provide a better performance.

{exp:weblog:entries weblog="my_weblog"}
..
..
{reverse_related_entries weblog="myother_weblog"}
  {categories}
    {if category_id
=="5"}
      {embed
="globals/.album_item" pass_entry_id="{entry_id}"}
    {
/if}
  {
/categories}
{
/reverse_related_entries}
{
/exp:weblog:entries}

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65102 Total Logged-in Users: 58
Total Topics: 82263 Total Anonymous Users: 28
Total Replies: 442113 Total Guests: 241
Total Posts: 524376    
Members ( View Memberlist )