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

przekazywanie zmiennych !?

 
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
Fellow
Smarty Rookie


Joined: 26 Mar 2007
Posts: 7

PostPosted: Tue Jan 18, 2011 4:39 pm    Post subject: przekazywanie zmiennych !? Reply with quote

Mam taki problemik a nie mam pomyslu. Chodzi o to ze chce napisac warunek, ktory jest przyrownany do zmiennej i wg tej zmiennej zostanie zaladowany plik tpl. Moze lepiej na przykladzie:
mamy index.php:
Code:

.....
// jezeli jest przegladany dzial i rowny jest on z ze zmienna $nazwadzialu
// nazwy dzialow pobieramy z bazy mysql

if ($_GET['Dep'] == $nazwadzialu)
{
// ladujemy tpl o takiej nazwie jaka otrzymala z bazy mysql zmienna
//$zmiennadzialu
   $trescstrony = $nazwadzialu".tpl";
}
$smarty->assign("trescstrony", $trescstrony);
$smarty->display('index.tpl');
.....


a w index.tpl
....
Code:

{include file = $trescstrony}
.....

Spewnoscia sa bledy w powyzszym kodzie, ale chodzi mi glownie o jakies rozwiazanie o ile jest to mozliwe. Z gory dziekuje za jakies sugestie.
Back to top
View user's profile Send private message
elmozaur
Smarty Rookie


Joined: 19 Jun 2011
Posts: 6

PostPosted: Sun Jun 19, 2011 4:49 pm    Post subject: Reply with quote

pomysl nawet ok ale zamiast ifa lepiej uzyc switcha.
W swichu mozesz sobie zdefiniowac pozycje default czyli jesli zaden warunek z geta nie zostanie spelniony
Back to top
View user's profile Send private message Send e-mail
Unk
Smarty n00b


Joined: 24 Mar 2011
Posts: 2

PostPosted: Sat Jul 02, 2011 5:50 pm    Post subject: Reply with quote

Zapisz nazwy działów do tablicy, a później wykorzystaj in_array:
http://php.net/manual/en/function.in-array.php
Back to top
View user's profile Send private message Visit poster's website
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