3

My orignal website is a Onepager but I am creating a individual news page.

Is it possible to extend a block to another page taking over the content from that single? I have a block filled with a really big Matrix field which I cant have on my other page cause I only need a small amount of content from it. This content is placed inside a block so I need to extend just that block.

What I need is to extend the {% block navigation %} and not the entire page

See it as this:

{% block navigation %}
  {% for block in entry.blokken %}
    {% if block['opnemenInNavigatie'] is defined and block.opnemenInNavigatie %}
       <li>
        {% if block.navigatieNaam | slugify == 'news' %}
         <a href="/{{ block.navigatieNaam | slugify }}">          
          {{ block.navigatieNaam }} 
        </a>
       {% endif %}
      </li>
    {% endif %}
  {% endfor %}
{% endblock %}

And also this:

{% block content %}
    {% for block in entry.blokken %}
        {% include 'blocks/' ~ block.type ~ '.html' %}
    {% endfor %}
{% endblock %}
2
  • I'm not 100% following your question, but take a look at the Twig extend tag, I think that might be what you need twig.sensiolabs.org/doc/tags/extends.html
    – Jamie Wade
    Aug 6 '15 at 10:13
  • Let me say it different because a posibillity might be setting a block in a variable that would do the deal too Aug 6 '15 at 10:20
3

I'd just put whatever you want to share into an include. Also you shouldn't need the .html either as craft should find the file

2
  • The solution was putting it all in a "set" variable and worked out fine now but it actually needs the .html because it is searching for just .html files in the blocks folder which is good because i have other types of files there some of them with the same name. Thanks for the answer though :D Aug 13 '15 at 13:52
  • Right on! Glad you were able to get it sorted out! Aug 13 '15 at 15:14

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.