ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Paginate Reverse Related Entry Results?

September 17, 2011 6:06am

Subscribe [3]
  • #1 / Sep 17, 2011 6:06am

    karlosb

    43 posts

    Hi There,

    I know this is not allowed by default but:

    Does anyone know how to paginate the results of reverse_related entries?

    What I have are a series of ‘surgerys’ channel entries with related ‘doctors’ entries.

    Here is the code (simplified down for demonstration):

    (I’m using EE 2.2.2 by the way).

    {exp:channel:entries channel="surgerys" limit="1" paginate="top"}
                
        {paginate}                
    
           {total_pages} {pagination_links}
    
        {/paginate}
    
        {reverse_related_entries id="doctors"}
            
           {doctors_name}
    
        {/reverse_related_entries}
    
    
    {/exp:channel:entries}

    I’ve searched the EE Forums (& Googled this issue) for a workaround,
    and I did find the following from Erskine: https://github.com/erskinedesign/ed.related.ee_addon
    (via this EE forum thread http://ellislab.com/forums/viewthread/152971/#745668):

    But it appears to be a module for EE1 (I’m using in EE 2.2.2).

    I’m wondering if there is a way of doing this with embedded templates / SQL Entry calls etc?

    Does anyone have any suggestions?

    Many thanks in advance! 😊

    Regards

    Karl

  • #2 / Sep 18, 2011 4:18pm

    Kevin Smith

    4784 posts

    Hi Karl,

    There’s nothing native that allows this nor any third-party add-ons that I know of that will help accomplish it, but perhaps others in the community might be able to help you put together a custom solution. Would you like me to move this to Community Help where others in the community can help you with that?

  • #3 / Sep 18, 2011 6:12pm

    karlosb

    43 posts

    Hi Kevin,

    Many thanks for the feedback on this.

    Yes it maybe useful to move this topic over to ‘community help’ as suggested.

    Brandon Kelly over at Pixel & Tonic has been quite helpful and confirmed that it is possible using their commercial add-on ‘Playa’ which has the {exp:playa:child_ids} and {exp:playa:parent_ids} tags, so you can just pass the parent entry IDs into a paginated {exp:channel:entries}.

    I’m going to give this a go and see what happens!

  • #4 / Sep 19, 2011 12:31am

    John Henry Donovan

    12339 posts

    Moving it for you Karl. Nice to know that Playa does it. Let us know how you get on.

  • #5 / Sep 19, 2011 6:55am

    karlosb

    43 posts

    Hi John,

    Hope all is well 😊

    Many thanks for transferring this thread over.

    To confirm:

    Success! I actually got paginated reverse related entries working with Playa.

    I used the sample code at the bottom of this tech support
    thread over at Pixel & Tonic tech support:
    http://help.pixelandtonic.com/brandonkelly/topics/pagination_in_playa
    (the last post from Brandon shows the code).

    My actual version of the code is this:

    Main template:

    {exp:channel:entries channel="surgerys" limit="1" sort="asc" disable="categories|member_data"}
                            
        {embed="surgerys/paginated_entries_template" entry_ids="{exp:playa:parent_ids channel="doctors"}"}
    
    {/exp:channel:entries}

    The Embed template (‘paginated_entries_template’):

    {exp:channel:entries dynamic="no" limit="4" fixed_order="0|{embed:entry_ids}" paginate="top"}
        
            {paginate}                
        
                {pagination_links}
                                            
            {/paginate}
            
            {doctors_details_field}
        
    {/exp:channel:entries}

    I hope this helps with anyone having a similar issue!

    Once again many thanks for all input! 😊

  • #6 / Sep 20, 2011 11:11am

    Kevin Smith

    4784 posts

    Glad you were able to figure out a solution with Brandon, and thanks for posting your results back here for the rest of the community to see!

  • #7 / Sep 20, 2011 12:21pm

    karlosb

    43 posts

    Many thanks for the feedback Kevin,

    I’m glad to have been able to provide some useful feedback to the community here at the forums! 😊

    Regards

    Karl

  • #8 / Feb 28, 2012 8:32pm

    kscot

    91 posts

    Karl, thanks for posting this solution. I generally use Playa on every site I develop, and was trying to get away without using it on the current one I’m developing, but this pagination feature was a must-have. Hard to believe it doesn’t work with reverse_related_entries.

    Thanks again!

  • #9 / Feb 29, 2012 6:32am

    karlosb

    43 posts

    Hi kscot,

    No worries, I’m glad you got sorted with the solution. 😊

    Regards

    Karl

  • #10 / Mar 05, 2012 3:49pm

    padstow

    101 posts

    THANK YOU so much for your detailed instructions on making this work - this is exactly what I needed and I was trying to get the native reverse related entries function to do it, but now I’ve got Playa in place and with your posted code, I’m golden. 

    So thank you, thank you for taking the time to post your solution!  (and thank heavens for Brandon at P&T…)

  • #11 / Mar 06, 2012 5:59am

    karlosb

    43 posts

    No problem Padstow any time 😊

    I’m actually pretty glad I’ve been able to give something back to the support community here as I received plenty of help and found various resources to help me with my EE tech issues etc.

    Regards

    Karl 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases