Answers.Body: <p>Your will need to set up a route for the entry1 section.</p>
  
  <p>For example, if your entry1 uri is looke like entry1section/{slug}, and your template is like "_entry1section/index" then the route would be</p>
  
  <p>entry1section/{slug}/* to "_entry1section/index"</p>
  
  <p>Then in the template, using </p>
  
  <pre><code>{% set lastSegment = craft.request.getLastSegment() %}
  {% set all_slug_in_entry1_section = someFunctionToRetrieveSlug() %}
  {% set all_slug_in_entry2_section = someFunctionToRetrieveSlug() %}
  
  {% if lastSegment in all_slug_in_entry1_section %}
  
    {# means your request url is {siteUrl}entry1section/{slug} #}
    {# display the content from entry1 #}
  
  {% elseif lastSegment in all_slug_in_entry2_section %}
  
    {# means your request url is {siteUrl}entry1section/{entry1-slug}/{entry2-slug} #}
    {# display the content from entry2 #}
  
  {% else %}
  
    {% redirect '404.html' %}
  
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-23T04:17:09.153Z
Answers.LastActivityDate: 2018-11-23T04:17:09.153Z
Answers.UserDisplayName: Parry Huang
Body: <p>My entries within specific section can be related to each other using "Entries" field.</p>
  
  <p>If entry1 "Entries" field is filled with entry2, i want to entry2 url look like this:</p>
  
  <pre><code>entry1/entry2
  </code></pre>
  
  <p>How can this be acomplished?</p>
  
Tags: <url>
Title: Query for entry related to current entry in section URI settings
ThreadText: # Query for entry related to current entry in section URI settings
  
  (Asked by: username_0 on 2018-11-21)
  
  My entries within specific section can be related to each other using "Entries" field.
  
  If entry1 "Entries" field is filled with entry2, i want to entry2 url look like this:
  
  ```
  entry1/entry2
  
  ```
  
  How can this be acomplished?
  
  **Tags:** url
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-23. Score: 1
  
  Your will need to set up a route for the entry1 section.
  
  For example, if your entry1 uri is looke like entry1section/{slug}, and your template is like "\_entry1section/index" then the route would be
  
  entry1section/{slug}/\* to "\_entry1section/index"
  
  Then in the template, using
  
  ```
  {% set lastSegment = craft.request.getLastSegment() %}
  {% set all_slug_in_entry1_section = someFunctionToRetrieveSlug() %}
  {% set all_slug_in_entry2_section = someFunctionToRetrieveSlug() %}
  
  {% if lastSegment in all_slug_in_entry1_section %}
  
    {# means your request url is {siteUrl}entry1section/{slug} #}
    {# display the content from entry1 #}
  
  {% elseif lastSegment in all_slug_in_entry2_section %}
  
    {# means your request url is {siteUrl}entry1section/{entry1-slug}/{entry2-slug} #}
    {# display the content from entry2 #}
  
  {% else %}
  
    {% redirect '404.html' %}
  
  {% endif %}
  
  ```
  
  
  ---
  
  