Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [smarty] get, include
krystian1991x
post
Post #1





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

Ostrzeżenie: (10%)
X----


jak mam wstawić zmienną zamiast nazwy pliku ?
  1. {include_php file=zmienna.php}


dodam że tak nie działa
  1. {include_php file="$zmienna.php"}

  1. {include_php file=$zmienna.php}

  1. {include_php file="$zmienna".php}


help !

Ten post edytował krystian1991x 15.10.2010, 12:37:50
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
krystian1991x
post
Post #2





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

Ostrzeżenie: (10%)
X----


index.php
  1. <?php
  2. require('libs/Smarty.class.php');
  3. require('cfg.php');
  4.  
  5. $smarty = new Smarty;
  6.  
  7. $_GET['id'];
  8.  
  9.  
  10. $smarty->assign("site", $_GET['id']);
  11.  
  12. $smarty->display('index.tpl');
  13.  
  14. ?>
  15.  

index.tpl
  1. <!doctype html public "-//w3c//dtd html 4.01 transitional//en">
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  4. <meta name="generator" content="pspad editor, www.pspad.com">
  5. <link rel="stylesheet" type="text/css" href="templates/style.css" />
  6. </head>
  7. <body>
  8. <div id="site">
  9. <div id="head">
  10. <div id="login">
  11. {include_php file="login.php"}
  12. </div>
  13. </div>
  14. <div id="menu">
  15. <div style="padding-left: 35px;">
  16. <table cellspacing="0" cellpadding="0"><tr>
  17. <td><a href="index.php?id=news"><img border="0" src="templates/images/aktualnosci.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  18. <td><a href="index.php?id=comments"><img border="0" src="templates/images/multimedia.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  19. <td><a href="#"><img border="0" src="templates/images/download.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  20. <td><a href="#"><img border="0" src="templates/images/artykuly.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  21. <td><a href="#"><img border="0" src="templates/images/forum.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  22. <td><a href="#"><img border="0" src="templates/images/faq.jpg"></a></td><td><img border="0" src="templates/images/kreska.jpg"></td>
  23. <td><a href="#"><img border="0" src="templates/images/kontakt.jpg"></a></td>
  24. </tr></table>
  25. </div>
  26. </div>
  27. <div>
  28.  
  29. {if $site ==""}
  30. {$site}
  31. zmienna site jest pusta
  32. {include_php file="news.php"}
  33. {/if}
  34. {if $site !=""}
  35. {$site}
  36. zmienna site posiada wartosc
  37. {include_php file="`$site`.php"}
  38. {/if}
  39.  
  40. </div>
  41. </div>
  42. </body>
  43. </html>
Go to the top of the page
+Quote Post

Posty w temacie
- krystian1991x   [smarty] get, include   14.10.2010, 23:53:20
- - nospor   Mi bez problemu działa ta metoda: {include_php fil...   15.10.2010, 06:03:38
- - krystian1991x   ta zmienna jest przekazywana jako get z pliku tpl ...   15.10.2010, 12:38:40
- - rocktech.pl   Widzę, że nie jesteś uważnym słuchaczem. Moja odpo...   15.10.2010, 12:50:55
- - krystian1991x   Fatal error: Uncaught exception 'Exception...   15.10.2010, 13:19:33
- - rocktech.pl   Wedle tego powinno zadziałać. Coś ci się źle par...   15.10.2010, 13:27:31
- - krystian1991x   to prowadzi mnie do punktu wyjścia a pisałem wyżej...   15.10.2010, 15:06:33
- - rocktech.pl   Pokaż cały kod w obecnej postaci. .php i .tpl. Zer...   15.10.2010, 15:28:12
- - krystian1991x   index.php [PHP] pobierz, plaintext <?phpsession...   15.10.2010, 15:34:40
- - rocktech.pl   Ok pokaż jeszcze co się dzieje w pliku np. news.ph...   15.10.2010, 15:50:53
- - krystian1991x   [PHP] pobierz, plaintext <?php session_start...   15.10.2010, 16:08:35
- - rocktech.pl   No i wyszło szydło z worka. To co się dzieje w pli...   15.10.2010, 16:35:53
- - krystian1991x   zrobiłem tak jak napisałeś ale cóż nie działa   15.10.2010, 16:55:43
- - rocktech.pl   1. Jakie błędy wywala? 2. index.php?id=news - tera...   15.10.2010, 17:07:11
- - krystian1991x   nie wywala błędów a dubluje mi news.php czyli wyśw...   15.10.2010, 17:12:44
- - rocktech.pl   To do wywalenia z index.php zakładając, że kod log...   15.10.2010, 17:13:36
- - krystian1991x   nie login.php jest osobno ładowany i nie jest pod ...   15.10.2010, 17:15:00
- - rocktech.pl   Możesz pokazać kod pliku login.php ?   15.10.2010, 17:24:23
- - krystian1991x   [PHP] pobierz, plaintext <?php session_start...   15.10.2010, 17:26:38
- - rocktech.pl   Nie wiem dlaczego się upierasz żeby całą logikę ap...   15.10.2010, 17:47:00
- - krystian1991x   ale co ma do tego login.php ? skoro nawet jak go n...   15.10.2010, 17:54:04
- - rocktech.pl   Kiedy ci tłumacze, że robisz wszytko źle i cała ob...   15.10.2010, 18:58:23
- - krystian1991x   Powiedz że nie wiesz co jest źle a nie gadaj od rz...   15.10.2010, 19:00:50
- - rocktech.pl   Ja wiem co jest źle tylko ty masz problem ze zrozu...   15.10.2010, 23:04:17
- - krystian1991x   uwierz że wystarczyło displays usunąć z podstron   16.10.2010, 12:06:17


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: 6.10.2025 - 23:55