Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem z przekazaniem zmiennych z php do tpl

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish
View previous topic :: View next topic  
Author Message
aleksanderlech
Smarty n00b


Joined: 15 Mar 2007
Posts: 1

PostPosted: Thu Mar 15, 2007 11:23 am    Post subject: Problem z przekazaniem zmiennych z php do tpl Reply with quote

Witam, troche nowy jestem w Smarty i mam taki problem:

index.php includuje inne pliki php ktore wczytuja szablony.

Jest taka sytuacja ze sprawdzam w pliku pierwszy.php wartosc zmiennej i na jej podstawie robie include() pliku drugi.php w ktorym obrabiam dane. Dane przypisuje do zmiennych smarty przez $smarty->assign(); i wracam do pliku pierwszy.php. W nim wczytuje odpowiedni plik tpl ale zmiennych z pliku drugi.php w nim nie mam.

Problem - jak przekazac dane z pliku drugi.php do szablonu wczytanego przez plik pierwszy.php??

A to kawalek kodu:
plik pierwszy.php
Code:

f(i--warunki--){
   include($instTpl.'drugi.php');
   $smarty->assign('menu_left_file','menu.tpl');
   $smarty->assign('main_body_file','dane.tpl');      
}



plik drugi.php
Code:

       $smarty->assign($imie,$result["imie"]);
   $smarty->assign($nazwisko,$result["nazwisko"]);


plik dane.tpl
Code:

{$imie}
{$nazwisko}



A moze ja wogole zle to robie?

Licze na Wasza pomoc

Pozdrawiam
Olek
Back to top
View user's profile Send private message
V3rit4S
Smarty n00b


Joined: 18 Nov 2007
Posts: 0
Location: Poland

PostPosted: Mon Nov 19, 2007 12:31 am    Post subject: Reply with quote

Z tego co tu widz? to plik drugi.php powinien zawiera? co? takiego:
Code:
 $smarty->assign("imie",$result["imie"]);
   $smarty->assign("nazwisko",$result["nazwisko"]);


W sk?adni $smarty->assign pierwszym parametrem jest nazwa zmiennej w szablonie. Skoro wcze?niej nie poda?e? warto?ci zmiennej $imie i $nazwisko nie masz do czego si? odwo?a?.


{$imie} to w php $smarty->assign("imie", "jaka? wartosc lub zmienna");

albo zrób po prostu

$imie = 'imie';

Wink Pozdrawiam
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP