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.

Limit Returned entries by Relationship field value

February 22, 2011 1:00pm

Subscribe [2]
  • #1 / Feb 22, 2011 1:00pm

    Scott Boyde

    208 posts

    I have a channel called Players and a custom field in this channel called Club which is a relationship field to Clubs channel.

    I also have a custom member field {exec_club} that has the entry_id for a club.

    I would like to list the players that I have added for a particular and this needs to match the custom field {exec_club}.

    Should I do this by using a query or is there any other way to do this. And if I have to use a query any pointers how to do it.

    Thanks

  • #2 / Mar 20, 2011 7:06am

    Scott Boyde

    208 posts

    Has no one any ideas how I can do this or help me with the query.

  • #3 / Mar 20, 2011 9:45am

    John St-Amand

    865 posts

    Are you passing the club ID into the url?  Then you could use the segment in the search parameter on your entries tag for the players channel.  So you’d add, for example:

    search:player_club="{segment_3}"

    Hope that helps.

  • #4 / Mar 20, 2011 12:01pm

    Scott Boyde

    208 posts

    Are you passing the club ID into the url?  Then you could use the segment in the search parameter on your entries tag for the players channel.  So you’d add, for example:

    search:player_club="{segment_3}"

    Hope that helps.

    I have the club entry_id as a custom member field.

  • #5 / Mar 20, 2011 12:14pm

    Scott Boyde

    208 posts

    I have used the following

    {exp:query sql="SELECT title FROM exp_channel_titles t JOIN exp_relationships ON t.entry_id = exp_relationships.rel_parent_id WHERE t.channel_id = '6' AND exp_relationships.rel_child_id = '6793' order by title"}

    Just have to substitute the 6793 for the custom field now.

    I tried the code you gave and it just listed all clubs.  But where did you get the player_club.

  • #6 / Mar 20, 2011 12:26pm

    John St-Amand

    865 posts

    Are you using this is a display template for a specific club?  And so you’re looking to display the players associated with that club, is that right?  And the club ID field is in the players field group?  What is the interaction with the member field?  Displaying just the players associated with a given club should be simple enough using the relationship field you have now.  The example I gave you would only work if you pushed the club ID into the URL in order to filter the player list based on the club you are viewing (and of course the segment number was just an example).  How does the member field play into the display other than to identify to the logged in member which club is their “home” club?

  • #7 / Mar 20, 2011 1:00pm

    Scott Boyde

    208 posts

    Are you using this is a display template for a specific club?  And so you’re looking to display the players associated with that club, is that right?  And the club ID field is in the players field group?  What is the interaction with the member field?  Displaying just the players associated with a given club should be simple enough using the relationship field you have now.  The example I gave you would only work if you pushed the club ID into the URL in order to filter the player list based on the club you are viewing (and of course the segment number was just an example).  How does the member field play into the display other than to identify to the logged in member which club is their “home” club?

    Are you using this is a display template for a specific club?
    Yes

    And so you’re looking to display the players associated with that club, is that right?
    Yes

    And the club ID field is in the players field group?
    I think so, I have a Relationship field in players channel to clubs channel.

    How does the member field play into the display other than to identify to the logged in member which club is their “home” club?

    I didn’t know what else to do to limit a members access to update club, team and player information associated with an overall club.

    I get the club info by using the following.

    {exp:member:custom_profile_data}
    {exp:channel:entries channel="clubs" disable="categories|member_data|pagination" dynamic="no" entry_id="{exec_club}"}
    <h5>Club Info:</h5>
    <p>{/exp:channel:entries}<br />
    {/exp:member:custom_profile_data}

    The team info uses the custom field

    {exp:member:custom_profile_data}
    {exp:channel:entries channel="clubs" disable="categories|member_data|pagination" cache="yes" dynamic="no" entry_id="{exec_club}"}
    {embed="clubhouse/team_list" entry_ids="{club_teams orderby="entry_id" sort="desc" }{entry_id}|{/club_teams}"}
    {/exp:channel:entries}
    {/exp:member:custom_profile_data}

    I wasn’t too sure how the players where going to be added and what relationship to use between, teams and club as a player may play for each team within that club.

    To get me started I thought that adding a relationship field between player and club as I have the entry_id in the custom field.

    The SAEF for adding players will somehow add the club relationship using the custom field.

    For listing the players I wanted to limit them by using the club relationship and custom field. This will then be used to edit the individual players and hopefully also allow me to add them into a fixture as playing.

    Hope that makes sense.

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

ExpressionEngine News!

#eecms, #events, #releases