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.

Conditional display of repeated related entries

February 07, 2011 11:49am

Subscribe [3]
  • #1 / Feb 07, 2011 11:49am

    Fruit Studios

    20 posts

    Hi Guys,

    I having some difficulty working with related entries, i’m not sure I even have the channel entries set up perfectly but being my first EE website its all new to me!

    I have two channels named ‘children’ and ‘rooms’. The children channel has a custom field (relationship) which link it to a specific room. It also has a custom field (third party fieldtype) which links it to a specific member account. This way I can display only children which belong to a specific member.

    I have a dashboard which I need to display the children and rooms that are associated to the logged in member (parent), my issue arises when displaying the list of rooms that a parent has children in.

    I use the {related_entries id=""} tag to get the rooms related to a child, but I cant then determine if a room has already been listed, it is possible a parent may have two children in the same room, and I don’t want to list that room more than once in the list of rooms associated to a parent.

    I’m not sure if the solution is EE, PHP, or a entirely different approach, your thoughts would be really appreciated!!

    
    <strong>My Children</strong>
                    <ul>
                    {exp:channel:entries status="Open" channel="children" dynamic="no"}
                    
                        {if no_results}Whoops! No Children Entries Found{/if}
    
                        {if logged_in_member_id == "{child_parent get="member_id"}"}
                        
                            {exp:imgsizer:size src="{child_image}" width="60" height="60"}
                                <li><a href="http://{title_permalink=%27parents/child%27}" title="{title}">{sized} {title}</a></li>
                            {/exp:imgsizer:size}
                            
                        
                        {/if}
    
                    {/exp:channel:entries}
                    </ul>                    
                    
                    
    <strong>My Children's Rooms</strong>
                    <ul>
                    {exp:channel:entries status="Open" channel="children" dynamic="no"}
                    
                        {if no_results}Whoops! No Children Entries Found{/if}
    
                        {if logged_in_member_id == "{child_parent get="member_id"}"}
    
                            {related_entries id="child_room"}
    
                                {exp:imgsizer:size src="{room_icon}" width="60" height="60"}
                                    <li><a href="http://{title_permalink=%27parents/room%27}/about" title="{title}">{sized} {title}</a></li>
                                {/exp:imgsizer:size}
                                
                            {/related_entries}
                        
                        {/if}
    
                    {/exp:channel:entries}

     

     

    Being quite new to EE i’m still learning the best practices for achieving things that I know how to do with PHP, I would really appreciate yor thoughts into this specific issue and any general feedback / resources you might have regards working with php within the EE templates.

    Many thanks,

    Sam

  • #2 / Feb 08, 2011 4:20am

    John Henry Donovan

    12339 posts

    Sam,

    This is more of a how to question so I’m going to move this thread over to the CodeShare Corner so you can get some community help. Nothing springs to mind straight away from myself only you are right in that you will have to use some custom PHP or a query

  • #3 / Mar 21, 2011 11:51pm

    aircrash

    293 posts

    Sam,

    Did you ever find a solution to this? I have a similar problem with a relationship field.

  • #4 / Mar 24, 2011 6:23am

    Fruit Studios

    20 posts

    No not yet!

    I have actually come off this project for a few weeks, i’m back on it starting next week and will update the post if I do find a work around!

    Have you had any luck??

    Thanks

    Sam

  • #5 / Mar 24, 2011 9:41am

    aircrash

    293 posts

    No, I’ve got some other bugs I need to work out before I get to the repeating entries. I’ll post here if I get it working, too.

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

ExpressionEngine News!

#eecms, #events, #releases