Answers.Body: <p>You can use an <a href="https://craftcms.com/docs/5.x/reference/element-types/entries.html#querying-entries" rel="nofollow noreferrer">entry query</a> to find all entries that a given entry is related to. The following assumes that the <code>entry</code> variable is an entry in your call to action channel.</p>
  <pre class="lang-twig prettyprint-override"><code>{% set entriesUsingCTA = craft.entries()
      .relatedTo({ targetElement: entry })
      .all()
  %}
  </code></pre>
  <p>You can further limit this to specific sections or specific fields if needed, see the <a href="https://craftcms.com/docs/5.x/system/relations.html" rel="nofollow noreferrer">documentation on relations</a> for details.</p>
  <p>If you want to this information directly in the entry form, you can place a <a href="https://craftcms.com/docs/5.x/system/fields.html#ui-elements" rel="nofollow noreferrer">template UI element</a>. In the template, use the query above to find all related entries and output them as a list:</p>
  <pre class="lang-twig prettyprint-override"><code>&lt;ul&gt;
      {% for entry in entriesUsingCTA %}
          &lt;li&gt;&lt;a href=&quot;{{ entry.getCpEditUrl() }}&quot;&gt;
              {{ entry.title }}
          &lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-26T10:59:44.487Z
Answers.Text: Thanks so much for this, do you know if there is a way to do this in the CMS so the editors can review the used components?
Answers.UserDisplayName: Amy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-26T12:16:58.283Z
Answers.Text: @Amy … yes, see the last paragraph.
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-16T20:18:51.983Z
Answers.Text: Oh, totally missed that! Thanks so much for the help this is perfect.
Answers.UserDisplayName: Amy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-17T07:13:59.687Z
Answers.Text: @Amy You're welcome. Don't forget to mark the answer as accepted ;)
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-26T09:24:27.650Z
Answers.LastActivityDate: 2024-06-26T09:24:27.650Z
Answers.UserDisplayName: MoritzLost
Body: <p>I'm looking to see if there is a way to locate all the instances/pages a channel item exists on in the CMS. In this situation we have a channel for call to action panels that can be added to any page created in the CMS.
  Is there a way to work out what all the pages are that the item is added to so I can be sure amending the content in a CTA panel will work in all of the locations it has been added to.
  Any help would be greatly appreciated. :)</p>
  
Tags: <channels>
Title: Can you locate all the pages that a channel item has been added to?
ThreadText: # Can you locate all the pages that a channel item has been added to?
  
  (Asked by: username_0 on 2024-06-26)
  
  I'm looking to see if there is a way to locate all the instances/pages a channel item exists on in the CMS. In this situation we have a channel for call to action panels that can be added to any page created in the CMS.
  Is there a way to work out what all the pages are that the item is added to so I can be sure amending the content in a CTA panel will work in all of the locations it has been added to.
  Any help would be greatly appreciated. :)
  
  **Tags:** channels
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-06-26. Score: 2
  
  You can use an [entry query](https://craftcms.com/docs/5.x/reference/element-types/entries.html#querying-entries) to find all entries that a given entry is related to. The following assumes that the `entry` variable is an entry in your call to action channel.
  
  ```twig
  {% set entriesUsingCTA = craft.entries()
      .relatedTo({ targetElement: entry })
      .all()
  %}
  
  ```
  
  You can further limit this to specific sections or specific fields if needed, see the [documentation on relations](https://craftcms.com/docs/5.x/system/relations.html) for details.
  
  If you want to this information directly in the entry form, you can place a [template UI element](https://craftcms.com/docs/5.x/system/fields.html#ui-elements). In the template, use the query above to find all related entries and output them as a list:
  
  ```twig
  <ul>
      {% for entry in entriesUsingCTA %}
          <li><a href="{{ entry.getCpEditUrl() }}">
              {{ entry.title }}
          </a></li>
      {% endfor %}
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks so much for this, do you know if there is a way to do this in the CMS so the editors can review the used components?  
  > **username_1**: @username_0 … yes, see the last paragraph.  
  > **username_0**: Oh, totally missed that! Thanks so much for the help this is perfect.  
  > **username_1**: @username_0 You're welcome. Don't forget to mark the answer as accepted ;)  
  
  ---
  
  