Bem eu quero começar a usar o twig mas queria saber se é possivel ter um ficheiro base...
Código (HTML):
Mas renderizar assim:
Código (PHP):
Código (HTML):
Código (HTML):
<!-- base.twig -->
<!DOCTYPE html>
<html>
<head>
{% include '/default/head.twig' %}
</head>
<body>
<div id="content" style="border:1px black;">{% block content %}{% endblock %}</div>
<div id="footer">
{% block footer %}
{% include '/default/footer.twig' %}
{% endblock %}
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
{% include '/default/head.twig' %}
</head>
<body>
<div id="content" style="border:1px black;">{% block content %}{% endblock %}</div>
<div id="footer">
{% block footer %}
{% include '/default/footer.twig' %}
{% endblock %}
</div>
</body>
</html>
Mas renderizar assim:
Código (PHP):
//ErrorController
public function error404()
{
header('HTTP/1.0 404 Not Found', true, 404);
$templ = $this->View->loadTemplate('@error/404.twig');
echo $templ->display('/default/404.twig', array('title'=>'NEXUS'));
}
public function error404()
{
header('HTTP/1.0 404 Not Found', true, 404);
$templ = $this->View->loadTemplate('@error/404.twig');
echo $templ->display('/default/404.twig', array('title'=>'NEXUS'));
}
Código (HTML):
<!-- 404.twig -->
{% extends '/default/default.twig' %}
{% block content %}
<div class="container">
{% block title %}{{ title }}{% endblock %}
<h1>404 - Page not found</h1>
<div class="box">
<p class="red-text">This page does not exist.</p>
</div>
</div>
{% endblock %}
{% extends '/default/default.twig' %}
{% block content %}
<div class="container">
{% block title %}{{ title }}{% endblock %}
<h1>404 - Page not found</h1>
<div class="box">
<p class="red-text">This page does not exist.</p>
</div>
</div>
{% endblock %}