Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement inheritance using Twig in Phalcon?
    text
    copied!<p>Ok. I use Twig as a View engine and Phalcon version is 0.8</p> <p>Code of adapter I got from this repository: <a href="https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mvc/View/Engine" rel="nofollow">github</a> I made ​​a small modification in this code because I include Twig via composer. I will not describe these modifications because they are not significant.</p> <p>So. My directory structure of view is very simple:</p> <pre><code>app - views --- index.twig --- about ---- index.twig </code></pre> <p>Source of views/index.twig:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Phalcon PHP Framework&lt;/title&gt; &lt;/head&gt; &lt;body&gt; {% block content 'This is main page' %} &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And source of views/about/index.twig:</p> <pre><code>{% extends "index.twig" %} {% block content %} This is About page {% endblock %} </code></pre> <p>Also, I have controller About (AboutController.php) with single method </p> <pre><code>public function indexAction() </code></pre> <p>it's empty.</p> <p>Ok. Now. When I do a request for a page /about I expect to see there something like this:</p> <pre><code>This is About page </code></pre> <p>But I still see there content of views/index.twig:</p> <pre><code>This is main page </code></pre> <p>It's a bit strange to me. I reassign the block "content"!</p> <p>I did some checking in the template views/about/index.twig adding extra characters out of the block and I received an error from Twig:</p> <pre><code>A template that extends another one cannot have a body in "about/index.twig" </code></pre> <p>So. Any ideas?</p> <p>P.S. I think I should call in tpl views/index.twig method {{ content() }} but Twig knows nothing about this method.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload