Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SMARTY]Wczytanie w szablonie innego szablonu
haryb
post
Post #1





Grupa: Zarejestrowani
Postów: 137
Pomógł: 0
Dołączył: 9.11.2004
Skąd: Gdańsk

Ostrzeżenie: (0%)
-----


Mam następujący problem.
Mam plik php w którym jest odwołanie do głównego szablonu znajdującego się w katalogu templates

  1. <?php
  2. require("libs/Smarty.class.php");
  3. $smarty = new Smarty();
  4. $smarty->display('index.tpl');
  5. ?>


Plik szablonu index.tpl jest taki
  1. {include file="header.tpl"}
  2. {include file="top1.tpl"}
  3. {include file="top2.tpl"}
  4. {include file="center_main.tpl"}
  5. {include file="footer.tpl"}


I wszystko działa ok ale jeśli te pliki top1.tpl, top2.tpl znajdują się bezpośrednio w katalogu templates.
Teraz chce pogrupować tpl w katalogi np.
Tworze katalog w templates/content i wrzucam w niego plik center_main.tpl
Drugi katalog tworze w templates/const i wrzucam do niego reszte czyli top1.tpl, top2.tpl itd
I teraz modyfikuje plik index.tpl o dopisanie ścieżki do pozostałych szablonów czyli:

index.tpl
  1. {include file="const/header.tpl"}
  2. {include file="const/top1.tpl"}
  3. {include file="const/top2.tpl"}
  4. {include file="content/center_main.tpl"}
  5. {include file="const/footer.tpl"}


i wówczas przestaje wszystko działac i otwiera się pusta strona.
Gdzie jest bład?

pozdro
haryb

Ten post edytował haryb 20.06.2008, 11:17:33
Go to the top of the page
+Quote Post
JoShiMa
post
Post #2





Grupa: Zarejestrowani
Postów: 1 374
Pomógł: 149
Dołączył: 1.03.2006

Ostrzeżenie: (0%)
-----


Zgaduję, bo sama nie wiem, ale może powinno być tak:

  1. {include file="./const/header.tpl"}
  2. {include file="./const/top1.tpl"}
  3. {include file="./const/top2.tpl"}
  4. {include file="./content/center_main.tpl"}
  5. {include file="./const/footer.tpl"}


--------------------
Go to the top of the page
+Quote Post
haryb
post
Post #3





Grupa: Zarejestrowani
Postów: 137
Pomógł: 0
Dołączył: 9.11.2004
Skąd: Gdańsk

Ostrzeżenie: (0%)
-----


Niestety tak tez nie działa:(


pozdro
haryb
Go to the top of the page
+Quote Post
k3nsei
post
Post #4





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 25.06.2008

Ostrzeżenie: (0%)
-----


http://www.smarty.net/manual/en/language.f...ion.include.php
Go to the top of the page
+Quote Post
Spykaj
post
Post #5





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 30.05.2008
Skąd: Białystok

Ostrzeżenie: (0%)
-----


Nie chcę zakładać nowego tematu:
  1. {assign var='p' value=$r->get('style')}
  2. {include file="$p/logo.tpl"}


Da się to zrobić jedną linijką ?

Dlaczego
  1. {include file="`$r->get('style')`/logo.tpl"}


Nie chce działać ? Powinno imho :/

wyskakuje błąd:
Cytat
Catchable fatal error: Object of class register could not be converted to string in (bla bla bla...) on line 18 (to jest właśnie ta linia)


Ten post edytował Spykaj 11.07.2008, 16:47:58


--------------------
?>
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 20.08.2025 - 22:34