Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]TWIG problem
-Analka-
post
Post #1





Goście







Witam

Niemogę poradzić sobię z funkcją extend w TWIGu.

Struktura:

templates/
---default/
-------index.html
-------demo.html
-------footer.html
---oragneblue/
index.php

index.html:
  1. {% block footer %} {% endblock %}


footer.hml:
  1. {% extends "index.html" %}
  2.  
  3. {% block footer %}
  4.  
  5. (c) {{ "now"|date("Y") }}
  6.  
  7. {% endblock %}


i nic nie wyświetla gdy wejdę na strone główną tzn nie wyświetla stopki. I tu pytanie jak to załadować czy źle korzystam z extend? J
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-analka-
post
Post #2





Goście







index.php
  1. $loader = new Twig_Loader_Filesystem('./templates/'.$get_config[layout]);
  2. $twig = new Twig_Environment($loader, array(
  3. // 'cache' => 'cache', //Możliwość cachowania
  4. 'auto_reload' => true
  5. ));
  6. $template = $twig->loadTemplate($get_config['default_page'])


Myślałem że on wczytuje all pliki z danego folderu i łączy je jak mają extends bloki. Czy tak nie jest?


Jeżeli nawet podstrony to i tak jak wejdę na podstronę demo.html i umieszczę tam extends to mam błąd:
  1. Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'A template that extends another one cannot have a body in "demo.html" at line 1.' in
więc zapewne nie tędy droga.. :/ może źle wczytuje pliki w index.php?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.12.2025 - 12:28