Answers.Body: <p>Well, you can do:</p>
  
  <pre><code>{# Get segment 2 from the URL #}
  {% set company = craft.app.request.getSegment(2) %}
  
  {# Get content where myCompanyField matches segment 2 #}
  {% set entries = craft.entries.section('mySection').myCompanyField(company).all() %}
  </code></pre>
  
  <p>But I need to know more about the structure of your content.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-15T17:31:07.587Z
Answers.LastActivityDate: 2019-11-15T17:31:07.587Z
Answers.UserDisplayName: 4midori
Body: <p>I am building a site where I have users, companies and content.</p>
  
  <p>Currently my users are standard Craft users, and my companies and content are entries within a channel.</p>
  
  <p>I have a field in my content called company name which is an asset field and lets me create a relationship between a piece of content and a company and now I want to create a comaopny page that lists all content "owned" by that company.</p>
  
  <p>I have the below as a starting point which is listing all of my content but any help on what I'd need to do to tweak it so that it only displays content where company name is equal to the entry title (which is the company name)? Hopefully that makes some kind of sense!</p>
  
  <p>Many thanks in advance!</p>
  
  <pre><code>{% set relatedEntries = craft.entries()
      .companyName(':notempty:')
      .all() %}
  
  {% if relatedEntries|length %}
      &lt;ul&gt;
          {% for rel in relatedEntries %}
              &lt;li&gt;&lt;a href="{{ rel.url }}"&gt;{{ rel.title }}&lt;/a&gt;&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endif %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-14T19:18:40.533Z
Comments.Text: So, you have a 'companies' channel and a 'content' channel? How have you related the two channels?
Comments.UserDisplayName: 4midori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-15T09:59:29.667Z
Comments.Text: I have a field type (entries) that I use in my 'content' and choose the relevant company. As I say the above returns all content that has the company field filled out I just need to add logic that says only show those where companyName = entry.title
Comments.UserDisplayName: Chrisl2310
Tags: <templating><craft3>
Title: Related Entries Relationships
ThreadText: # Related Entries Relationships
  
  (Asked by: username_0 on 2019-11-13)
  
  I am building a site where I have users, companies and content.
  
  Currently my users are standard Craft users, and my companies and content are entries within a channel.
  
  I have a field in my content called company name which is an asset field and lets me create a relationship between a piece of content and a company and now I want to create a comaopny page that lists all content "owned" by that company.
  
  I have the below as a starting point which is listing all of my content but any help on what I'd need to do to tweak it so that it only displays content where company name is equal to the entry title (which is the company name)? Hopefully that makes some kind of sense!
  
  Many thanks in advance!
  
  ```
  {% set relatedEntries = craft.entries()
      .companyName(':notempty:')
      .all() %}
  
  {% if relatedEntries|length %}
      <ul>
          {% for rel in relatedEntries %}
              <li><a href="{{ rel.url }}">{{ rel.title }}</a></li>
          {% endfor %}
      </ul>
  {% endif %}
  
  ```
  
  **Tags:** templating, craft3
  
  > **Comments:**
  > **username_1**: So, you have a 'companies' channel and a 'content' channel? How have you related the two channels?  
  > **username_0**: I have a field type (entries) that I use in my 'content' and choose the relevant company. As I say the above returns all content that has the company field filled out I just need to add logic that says only show those where companyName = entry.title  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-15. Score: 1 | Accepted answer
  
  Well, you can do:
  
  ```
  {# Get segment 2 from the URL #}
  {% set company = craft.app.request.getSegment(2) %}
  
  {# Get content where myCompanyField matches segment 2 #}
  {% set entries = craft.entries.section('mySection').myCompanyField(company).all() %}
  
  ```
  
  But I need to know more about the structure of your content.
  
  
  ---
  
  