1

Perhaps I've misunderstood what Related_Entries is aimed at accomplishing, but I've tried a number of variations and can't seem to get some very simple template code to parse correctly.

Channel Setup

I've got a Matches channel and a Teams channel. The Matches channel has two fields in it labeled as "Team 1" and "Team 2". They're both set as a Relationship to the Teams channel. I've created some test Matches and assigned Teams to them and everything appears fine there. However, I'm attempting to create a sample template using all of this information. See below:

Template code

<!DOCTYPE html>
<html>
<head>
    <title>Matches</title>
    <meta charset="utf-8">
</head>
<body>
<h1>List of current matches.</h1>

{exp:channel:entries channel="Matches" limit="10"}
<h2>{title}</h2>

{related_entries id="Teams" entry_id="{team_1}"}
  {team_name}
{/related_entries}

vs

{related_entries id="Teams" entry_id="{team_2}"}
  {team_name}
{/related_entries}


{/exp:channel:entries}
</body>
</html>

{team_1} appears to just be returning an id of some sort... I presume it is the rel_id.

exp_relationships/clearing cache/table behavior

To further muddy the waters, while troubleshooting, it was recommended I clear the Relationship cache within EE through the Admin interface. This action cleared out all data within the rel_data column in this table but I've yet to find an ideal way to repopulate this data. The only way I've found is to go into Content > Edit > Matches, edit one of the matches and CHANGE the team participating in the Match and then change it back. Simply hitting "Update" doesn't appear to re-populate the table.

EDIT: SOLUTION

I made a mistake and read the documentation on the related_entries tag incorrectly. The accepted answer below is based on the comment he made pointing out that I need to use the field id instead of the Channel name.

The changed line(s) should look something like

{related_entries id="team_1"}
0

Try removing entry_id="" the only parameter to the related_entries tag is the id parameter, which is the shortname of the relationship field. This means the name of the field where the dropdown allowing you to select a relationship lives. As an example, I have a channel called programs in which the channel field naming convention is three letter channel code underscore 2 letter language code underscore name. Here is my code for one of those related_entries tags:

{related_entries id="pro_related_program"}
    <p>This session is part of a larger series.  For more information see <a href="{title_permalink="programs/catalogue"}" title="TDLC: {title}">{title}</a></p>
{/related_entries}
5
  • That doesn't seem to return anything either. That's was the first thing I had tried based on the documentation. I appreciate the input though. The way it was described to me was that if I provided only that information, EE would try to return ALL the members of that channel and I only want a specific one. – kreeves Jan 22 '13 at 2:57
  • To elaborate a bit, the {title} prints fine however the code between {related_entries} returns nothing. If I use the code as I presented up above, it at least returns an Integer which appears to relate to the rel_id. – kreeves Jan 22 '13 at 3:02
  • id="" should not contain a channel, it should contain the name of the field where you've defined the relationship. – UltraBob Jan 22 '13 at 5:20
  • That makes sense! Not sure why I never thought to just try that. I misinterpreted the documentation which in their example uses the same name for the Channel as well as the relationship field. Thank you. – kreeves Jan 22 '13 at 12:19
  • Might be worth adding a clarifying note at the end of the documentation too if using the same name caused confusion for you it is likely to confuse others too. Very glad I could help. – UltraBob Jan 23 '13 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.