1

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?

2
  • What kind of field is studentFee and what is fee set to?
    – Brad Bell
    Jul 26 '16 at 23:23
  • 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. Jul 27 '16 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.