0

I have a channel, loan-officers. Each entry in this channel has a related_entry field for each loan officer to choose which branch they are associated with. (the related_entry field is called officer_branch, and is a Relationship fieldtype.) Each loan officer can be associated with only one branch. The loan-officer template displays the information from the loan-officer channel, a single entry at a time.

On each loan-officer template, I want to display a link to the loan officer's associated branch. The information about the individual branches displays through the template "branch/index". I want the link text to be the branch name, which is the {title} tag of the related entry. The URL should be the 'branch' template group, plus the {url_title} of the related entry.

I have no idea what code to use for this. We have EE 2.5.5 installed, and so the documentation I can find via Google...doesn't work for our installation. (Running EE 2.5.5 on AWS.)

(This is possibly fairly obvious, but I haven't worked with EE's native related_entries tag too much. I don't even know if this is related_entries, or reverse_related_entries. Sorry!!)

  • Can you show us your template code, starting with the {exp:channel:entries ...} tag? – Stephen Callender May 11 '13 at 12:58
1

Inside your channel entries tag pair add this.

{related_entries channel="officer_branch"}
  <a href="/branch/{url_title}">{title}</a>
{/related_entries}
| improve this answer | |
  • Thanks, Stephan. I tried this, but unfortunately it wasn't working. It just displayed the raw code, not the variable. (I even doublechecked the quotation marks.) – user800 May 10 '13 at 20:30
0

If I understood you right and you are using url_title instead of entry_id as segment, this code should do the job on EECMS 2.5.5:

{exp:channel:entries channel="loan-officers"}
    {related_entries id="officer_branch" limit="1"}
      <a href="{url_title_path='branch'}">{title}</a>  
    {/related_entries}
{/exp:channel:entries}

The reverse_related_entries would be used on the page of the branch, to list the associated loan officers.

You can download the documentation to your version on the User Guide of ExpressionEngine.

By the way, it's always better to use the most recent version.

  • I agree with you on software versions...but we don't have the most recent version of PHP which is required by EE2.6 (not my choosing) and we may have other apps on the server which cannot run using PHP 5.2.4. And we don't have the personnel to test everything. If I had my druthers, server software would be kept up to date, with no more than a two-dotrev lag between versions. Sadly, this is not the case. We're lucky to actually have a separate dev environment. That's how backward these people are. (But, hey, the paychecks don't bounce. Yet.) – user800 May 10 '13 at 17:21
  • Robson, thank you for answering. I tried this solution, though, and it didn't work. I have a starting point, though, and thank you for sending me the user-guide link. I hadn't realized that they'd added the ability to download older versions of the documentation. – user800 May 10 '13 at 20:31
  • Please, forgive me, Leigh. I marked my answer as a community wiki. So, please, improve it after found the solution. I just improved it too. – Robson Sobral May 10 '13 at 22:00

Your Answer

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