Answers.Body: <p>CKEditor entries (and Matrix entries; collectively known as &quot;nested&quot; entries) in Craft 5 doesn't have a <em>parent</em> (like an entry nested in a structure section would) – they have an <em>owner</em>.</p>
  <p>To access the owner entry in a template partial, you can use the <code>entry.getOwner()</code> entry method (or just <code>entry.owner</code>, if you prefer that):</p>
  <pre><code>{% set owner = entry.getOwner() %}
  
  {% if owner %}
      &lt;p&gt;My owner is {{ owner.title }}&lt;/p&gt;
  {% endif %}
  </code></pre>
  <p>Also, worth mentioning that in addition to having an owner, nested entries also always belong to a <em>field</em> (i.e. the &quot;Copy&quot; CKEditor field, in your case).</p>
  <p>If you have a need to access that field from a nested entry's partial template (for example, to check the field's handle to confirm which field is being rendered) you can use the <code>entry.getField()</code> (or just <code>entry.field</code>) method in a similar manner:</p>
  <pre><code>{% set field = entry.getField() %}
  
  {% if field %}
      &lt;p&gt;I belong to the {{ field.handle }} field!&lt;/p&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-04T14:44:55.360Z
Answers.Text: I will see if I can create a pull request to add these details to the CKEditor documentation related to partials.
Answers.UserDisplayName: Jason
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-03T22:26:59.873Z
Answers.LastActivityDate: 2024-04-03T22:35:50.913Z
Answers.LastEditDate: 2024-04-03T22:35:50.913Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>Craft 5, CKEditor accessing parent entry from partial</p>
  <p>Is it possible to access the parent entry from a partial template being rendered from an embedded entry in a CKEditor field?</p>
  <p>For example, consider a &quot;Page&quot; entry type that has a &quot;Copy&quot; CKeditor field. The &quot;Copy&quot; field allows embedding a &quot;Video&quot; entry type. When the &quot;Copy&quot; field is rendered, it will render the embedded &quot;Video&quot; entry type using the <code>/templates/_partials/entry/video.twig</code> template. From the <code>video.twig</code> partial template, is it possible to access the &quot;Page&quot; entry type?</p>
  <p>This may be particularly useful if the &quot;Video&quot; entry type is embedded into different fields and entry types. For example, the &quot;Video&quot; might be rendered differently if it is part of a &quot;Page&quot; entry type vs a &quot;Blog&quot; entry type. As I see it right now, this would not be possible since each entry type can only have a single template and does not have access to it's parent.</p>
  <p>Related documentation:</p>
  <ul>
  <li><a href="https://craftcms.com/docs/5.x/system/elements.html#rendering-elements" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/system/elements.html#rendering-elements</a></li>
  <li><a href="https://github.com/craftcms/ckeditor?tab=readme-ov-file#rendering-nested-entries-on-the-front-end" rel="nofollow noreferrer">https://github.com/craftcms/ckeditor?tab=readme-ov-file#rendering-nested-entries-on-the-front-end</a></li>
  </ul>
  
Tags: <ckeditor5><craft5>
Title: Craft 5, CKEditor accessing parent entry from partial
ThreadText: # Craft 5, CKEditor accessing parent entry from partial
  
  (Asked by: username_0 on 2024-04-03)
  
  Craft 5, CKEditor accessing parent entry from partial
  
  Is it possible to access the parent entry from a partial template being rendered from an embedded entry in a CKEditor field?
  
  For example, consider a "Page" entry type that has a "Copy" CKeditor field. The "Copy" field allows embedding a "Video" entry type. When the "Copy" field is rendered, it will render the embedded "Video" entry type using the `/templates/_partials/entry/video.twig` template. From the `video.twig` partial template, is it possible to access the "Page" entry type?
  
  This may be particularly useful if the "Video" entry type is embedded into different fields and entry types. For example, the "Video" might be rendered differently if it is part of a "Page" entry type vs a "Blog" entry type. As I see it right now, this would not be possible since each entry type can only have a single template and does not have access to it's parent.
  
  Related documentation:
  
  * <https://craftcms.com/docs/5.x/system/elements.html#rendering-elements>
  * <https://github.com/craftcms/ckeditor?tab=readme-ov-file#rendering-nested-entries-on-the-front-end>
  
  **Tags:** ckeditor5, craft5
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-04-03. Score: 3 | Accepted answer
  
  CKEditor entries (and Matrix entries; collectively known as "nested" entries) in Craft 5 doesn't have a *parent* (like an entry nested in a structure section would) – they have an *owner*.
  
  To access the owner entry in a template partial, you can use the `entry.getOwner()` entry method (or just `entry.owner`, if you prefer that):
  
  ```
  {% set owner = entry.getOwner() %}
  
  {% if owner %}
      <p>My owner is {{ owner.title }}</p>
  {% endif %}
  
  ```
  
  Also, worth mentioning that in addition to having an owner, nested entries also always belong to a *field* (i.e. the "Copy" CKEditor field, in your case).
  
  If you have a need to access that field from a nested entry's partial template (for example, to check the field's handle to confirm which field is being rendered) you can use the `entry.getField()` (or just `entry.field`) method in a similar manner:
  
  ```
  {% set field = entry.getField() %}
  
  {% if field %}
      <p>I belong to the {{ field.handle }} field!</p>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: I will see if I can create a pull request to add these details to the CKEditor documentation related to partials.  
  
  ---
  
  