CMS: Craft CMS 2

In my admin panel I have globals set called X (under "Globals" from the sidebar and defined in craft_globalsets in the db from Global->Settings->New global set).

A field for the field layout for the global set is defined by using as Content a Field type Y of Matrix type with several plain texts fields A,B,C,...

How do I check/show such fields' values (A, B, C, ...) in twig?

What I have tried: I see that in the other parts of the code the handle defined in craft_globalsets (or equivalently in Settings->Globals) is used to fetch the globals' field value

e.g. for Globals -> set 'K' (handle in craft_globalsets: kHandle) there are several plaintext inputs and such are accessed in twig as:

{{ kHandle.firstField}}

and in fact it works - but when I od the same with set X


it's null

I have also tried to do

{% set matrixFields = craft.fields.getFieldByHandle('Y') %} {{ matrixFields }}

but this returned only the field name.

Perhaps I should do something like {{ xHandle.firstFiledInTheMatrix.getMatrixContent | getFieldContent }} and a for loop on this? (currently guessing the function names here)

1 Answer 1


You should be able to get your content by using a for loop on your Matrix field:

{% for blocks in kHandle.yourMatrixfieldHandle.all() %}
    {{ block.fieldHandle }}
{% endfor %}

Alternatively, if you only have one block in there, you could use:

{{ kHandle.yourMatrixfieldHandle.first().fieldHandle }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.