I just playing first time with Matrix and can't figure whats wrong with this code, here's error code:

Craft\MatrixBlockModel and its behaviors do not have a method or closure named "naglowekPowitanie".

Matrix field config: config

{% for block in entry.homepage %}
        {% if block.type == "powitanie" %}
            <article id="main">

                <header class="special container">
                    <span class="icon fa-truck"></span>
                    <h2>{{ block.naglowekPowitanie }}</h2>
                    <p>{{ block.trescPowitanie }}</p>

        {% elseif block.type == "wstep" %}
                    <section class="wrapper style2 container special-alt">
                        <div class="row 50%">
                            <div class="8u 12u(narrower)">

                                    <h2>{{ block.wstepNaglowek }}</h2>
                                <p>{{ block.wstepTresc }}</p>
                                    <ul class="buttons">
                                        <li><a href="#" class="button">{{ block.wstepPrzycisk }}</a></li>
        {% endif %}
{% endfor %}

On your screenshot of the block type powitanie you see two fields: powitanieNaglowek and powitanieTresc. Yet, in your code you try to use

  <h2>{{ block.naglowekPowitanie }}</h2>

The error simply says: in the block type you are using there is no field called naglowekPowitanie.

Changing that H2 to

  <h2>{{ block.powitanieNaglowek }}</h2>

should do the trick.

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.