As the title suggests, i'm trying to output the contents of a default instructions field within a Matrix block. I'm sure it's doable but not sure where to start?




I just searched this Stack Exchange and found an answer on how to get the field model from the templates: How can I output the Field Name in my template?

You can get any field with craft.fields, which returns a FieldModel:

 {% set field = craft.fields.getFieldbyHandle('field_handle') %}
 {{ field.name }}
 {{ field.instructions }}

Unfortunatelly, however, this won't work with fields within a Martix field. The getFieldbyHandle method is written for use in specific parts of the CP, where Craft knows the context the field is used in.

There's a getFieldbyId method though, which could work for your use case. The field's ID is independent from the context (inside Matrix or not).

  • Hi Carlcs, thanks for looking, I should have said i'd already tried the method you also found. I'll give the getFieldbyID a try.
    – Martin
    Jan 18 '16 at 9:20

Your Answer

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

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