Answers.Body: <p>I'm assuming that <code>groupChair</code> is an <a href="https://craftcms.com/docs/3.x/entries-fields.html" rel="nofollow noreferrer">entries field</a>, correct? So what you're expecting from <code>groupChair</code> is a related entry associated with the current entry through that field?</p>
  <p>The output you're seeing is the result of outputting an <a href="https://craftcms.com/docs/3.x/element-queries.html" rel="nofollow noreferrer">element query</a> directly, which is a common mistake. To actually get to the related entry, you need to <a href="https://craftcms.com/docs/3.x/element-queries.html#executing-element-queries" rel="nofollow noreferrer">execute the query</a> using <code>.all()</code> or <code>.one()</code> (depending on whether you want one or multiple related entries).</p>
  <p>Those methods will execute the query and return either an array of entries (<code>.all()</code>) or a single entry or null (<code>.one()</code>) if there is no result.</p>
  <p>The reason it works this way is that all relationship fields in Craft (Asset, Category, Entry fields, etc) return an <a href="https://craftcms.com/docs/3.x/element-queries.html#executing-element-queries" rel="nofollow noreferrer">element query</a> instead of returning the related elements directly. This gives you an opportunity to modify the query parameters before executing the query.</p>
  <p>Finally, once you have your related entry, you still need to specify a field to output – for example, the title. Here's an example that should work:</p>
  <pre><code>{% set groupChair = entry.groupChair.one() %}
  {% if groupChair %} 
      Group Chair: {{ groupChair .title }}
  {% endif %}
  </code></pre>
  <p>See the documentation pages linked above for more information.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-22T19:03:17.863Z
Answers.Text: Thank you, my colleague immediately shot back an answer about what was going on. Your answer worked. I was able to expand on that and pull in a bunch of data.
Answers.UserDisplayName: Tom Holloway
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-09T07:29:47.943Z
Answers.LastActivityDate: 2021-07-09T07:42:50.880Z
Answers.LastEditDate: 2021-07-09T07:42:50.880Z
Answers.UserDisplayName: MoritzLost
Body: <p>I have an Entry called Groups (I'm wondering if this might be some sort of reserved word issue)  and, with Twig, I can bring out the base fields of id and title with no issue but when I try to pull out the first user-defined field: <code>entry.groupChair</code>, it sends a bunch of jibberish (looks like code).  Snippet of Jibberish:</p>
  <pre><code>  O:28:&quot;craft\elements\db\EntryQuery&quot;:86:{s:8:&quot;editable&quot;;b:0;s:9:&quot;sectionId&quot;;N;s:6:&quot;typeId&quot;;N;s:8:&quot;authorId&quot;;N;s:13:&quot;authorGroupId&quot;;N;s:8:&quot;postDate&quot;;N;s:6:&quot;before&quot;;N;s:5:&quot;after&quot;;N;s:10:&quot;expiryDate&quot;;N;s:17:&quot;*defaultOrderBy&quot;;a:1:{s:16:&quot;entries.postDate&quot;;i:3;}s:11:&quot;elementType&quot;;s:20:&quot;craft\elements\Entry&quot;;s:5:&quot;query&quot;;N;s:8:&quot;subQuery&quot;;N;s:12:&quot;contentTable&quot;;s:12:&quot;[...much more omitted]  
  </code></pre>
  <p>I have tried clearing the layout and reloading it. I have permanently deleted the Groups entry and brought it back in with FeedMe. Still have the issue. Groups look and operate fine in the front end. I was concerned that maybe the variable wasn't defined and added a test for that, but with the jibberish, it's considered defined and it prints out on screen.</p>
  <pre><code>{% set myEntryQuery = craft.entries()
      .section('groups')
      .limit(40) 
      .order('title')
      %}
      
  {% set entries = myEntryQuery.all() %}
  
  {% block content %}
  
  &lt;ul&gt;
      {% for entry in entries %}
          &lt;li&gt;
              &lt;label&gt;
                 Group:({{entry.Id}}) {{ entry.title}} &lt;br&gt;
  
             {% if entry.groupChair is defined %} 
                &amp;nbsp; Group Chair: {{ entry.groupChair}}  |
             {% endif %}
              &lt;/label&gt;
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  
  {% endblock %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-09T07:19:34.857Z
Comments.Text: What field type is your `groupChair` field?
Comments.UserDisplayName: MoritzLost
Tags: <templating><entries>
Title: Twig Template spits out jibberish when trying to access user-defined fields
ThreadText: # Twig Template spits out jibberish when trying to access user-defined fields
  
  (Asked by: username_0 on 2021-07-08)
  
  I have an Entry called Groups (I'm wondering if this might be some sort of reserved word issue) and, with Twig, I can bring out the base fields of id and title with no issue but when I try to pull out the first user-defined field: `entry.groupChair`, it sends a bunch of jibberish (looks like code). Snippet of Jibberish:
  
  ```
    O:28:"craft\elements\db\EntryQuery":86:{s:8:"editable";b:0;s:9:"sectionId";N;s:6:"typeId";N;s:8:"authorId";N;s:13:"authorGroupId";N;s:8:"postDate";N;s:6:"before";N;s:5:"after";N;s:10:"expiryDate";N;s:17:"*defaultOrderBy";a:1:{s:16:"entries.postDate";i:3;}s:11:"elementType";s:20:"craft\elements\Entry";s:5:"query";N;s:8:"subQuery";N;s:12:"contentTable";s:12:"[...much more omitted]  
  
  ```
  
  I have tried clearing the layout and reloading it. I have permanently deleted the Groups entry and brought it back in with FeedMe. Still have the issue. Groups look and operate fine in the front end. I was concerned that maybe the variable wasn't defined and added a test for that, but with the jibberish, it's considered defined and it prints out on screen.
  
  ```
  {% set myEntryQuery = craft.entries()
      .section('groups')
      .limit(40) 
      .order('title')
      %}
      
  {% set entries = myEntryQuery.all() %}
  
  {% block content %}
  
  <ul>
      {% for entry in entries %}
          <li>
              <label>
                 Group:({{entry.Id}}) {{ entry.title}} <br>
  
             {% if entry.groupChair is defined %} 
                &nbsp; Group Chair: {{ entry.groupChair}}  |
             {% endif %}
              </label>
          </li>
      {% endfor %}
  </ul>
  
  {% endblock %}
  
  ```
  
  **Tags:** templating, entries
  
  > **Comments:**
  > **username_1**: What field type is your `groupChair` field?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-09. Score: 1
  
  I'm assuming that `groupChair` is an [entries field](https://craftcms.com/docs/3.x/entries-fields.html), correct? So what you're expecting from `groupChair` is a related entry associated with the current entry through that field?
  
  The output you're seeing is the result of outputting an [element query](https://craftcms.com/docs/3.x/element-queries.html) directly, which is a common mistake. To actually get to the related entry, you need to [execute the query](https://craftcms.com/docs/3.x/element-queries.html#executing-element-queries) using `.all()` or `.one()` (depending on whether you want one or multiple related entries).
  
  Those methods will execute the query and return either an array of entries (`.all()`) or a single entry or null (`.one()`) if there is no result.
  
  The reason it works this way is that all relationship fields in Craft (Asset, Category, Entry fields, etc) return an [element query](https://craftcms.com/docs/3.x/element-queries.html#executing-element-queries) instead of returning the related elements directly. This gives you an opportunity to modify the query parameters before executing the query.
  
  Finally, once you have your related entry, you still need to specify a field to output – for example, the title. Here's an example that should work:
  
  ```
  {% set groupChair = entry.groupChair.one() %}
  {% if groupChair %} 
      Group Chair: {{ groupChair .title }}
  {% endif %}
  
  ```
  
  See the documentation pages linked above for more information.
  
  > **Comments:**
  > **username_0**: Thank you, my colleague immediately shot back an answer about what was going on. Your answer worked. I was able to expand on that and pull in a bunch of data.  
  
  ---
  
  