Answer the question
In order to leave comments, you need to log in
Problem with block inheritance in twig
I decided to make the contents of the tag in the form of templates, since on each page some files are connected, some are not. I shoved all the possible content into a separate file with something like this:
{% block meta %}<meta http-equiv="Content-Type" content="text/html; charset=utf-8">{% endblock %}
{% block style %}<link rel="stylesheet" type="text/css" href="css/style.css">{% endblock %}
{% block jquery %}<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>{% endblock %}
{% block script %}<script src="js/script.js"></script>{% endblock %}
<head>
, I do the inserts I need like this: {% block meta %}{% endblock %}
etc., but the blocks are not connected. I tried to add the path to the inherited file to the beginning of the file with blocks, for example {% extends "../index.html" %}
, but to no avail. /css
/js
/templates
/nodes
-head.html
...
-index.html
-contacts.html
-about.html
/images
/includes
-index.php
-contacts.php
-about.php
Answer the question
In order to leave comments, you need to log in
Inheritance occurs with parents()
, i.e. inherit the template using extends and then inherit the parent methods in the body of the block:{% block meta %} parents() {% endblock %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question