Body: <p>I'm having difficulty returning a category from inside a matrix block.</p>
  
  <p>So I'm returning a student based on a studentNumber variable</p>
  
  <pre><code>{% set studentParams = {
      section : 'students',
      'studentNumber': studentNumber,
  } %}
  
  {% set student = craft.entries(studentParams).first() %}
  </code></pre>
  
  <p>I'm then returning the fee associated with this student</p>
  
  <pre><code>{% set fee = student.studentFee[0] ?? null %}
  </code></pre>
  
  <p>Inside this fee, I have a matrix block. Within that matrix block I have a field that is set using categories.</p>
  
  <pre><code>{#
      Looping through fee types to get the installment amounts for the course and various fee types.
      Currently not returning the FeeType title - Grant holder etc
  #}
  
  {% for block in fee.fee %}
  
      {% if block.firstInstallment is defined and block.firstInstallment is not null %}
          &lt;h1&gt;First Installment : {{ block.firstInstallment }} &lt;/h1&gt;
      {% endif %}
  
      {% if block.secondInstallment is defined and block.secondInstallment is not null %}
          &lt;h1&gt;Second Installment : {{ block.secondInstallment }} &lt;/h1&gt;
      {% endif %}
  
      {% if block.full is defined and block.full is not null %}
          &lt;h1&gt;Full :  {{ block.full }} &lt;/h1&gt;
      {% endif %}
  
      &lt;hr /&gt;
  {% endfor %}
  </code></pre>
  
  <p>I am able to return everything inside the Matrix block aside from the category field.</p>
  
  <p>Any idea why this might be?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-26T23:23:28.343Z
Comments.Text: What kind of field is `studentFee` and what is `fee` set to?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-27T06:00:56.853Z
Comments.Text: I'll add the obvious comment, but as I've seen several folks bit by it before, it might be worth confirming that your category field has related categories that would display in your template and that it isn't just an empty field causing the issue.
Comments.UserDisplayName: Ben Parizek
Tags: <templating><entries><matrix>
Title: Return Category from Inside Matrix
ThreadText: # Return Category from Inside Matrix
  
  (Asked by: username_0 on 2016-07-26)
  
  I'm having difficulty returning a category from inside a matrix block.
  
  So I'm returning a student based on a studentNumber variable
  
  ```
  {% set studentParams = {
      section : 'students',
      'studentNumber': studentNumber,
  } %}
  
  {% set student = craft.entries(studentParams).first() %}
  
  ```
  
  I'm then returning the fee associated with this student
  
  ```
  {% set fee = student.studentFee[0] ?? null %}
  
  ```
  
  Inside this fee, I have a matrix block. Within that matrix block I have a field that is set using categories.
  
  ```
  {#
      Looping through fee types to get the installment amounts for the course and various fee types.
      Currently not returning the FeeType title - Grant holder etc
  #}
  
  {% for block in fee.fee %}
  
      {% if block.firstInstallment is defined and block.firstInstallment is not null %}
          <h1>First Installment : {{ block.firstInstallment }} </h1>
      {% endif %}
  
      {% if block.secondInstallment is defined and block.secondInstallment is not null %}
          <h1>Second Installment : {{ block.secondInstallment }} </h1>
      {% endif %}
  
      {% if block.full is defined and block.full is not null %}
          <h1>Full :  {{ block.full }} </h1>
      {% endif %}
  
      <hr />
  {% endfor %}
  
  ```
  
  I am able to return everything inside the Matrix block aside from the category field.
  
  Any idea why this might be?
  
  **Tags:** templating, entries, matrix
  
  > **Comments:**
  > **username_1**: What kind of field is `studentFee` and what is `fee` set to?  
  > **username_2**: I'll add the obvious comment, but as I've seen several folks bit by it before, it might be worth confirming that your category field has related categories that would display in your template and that it isn't just an empty field causing the issue.  
  
  ---
  
  ## 0 answers
  
  