Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wybór szablonu poprzez formularz
Kshyhoo
post 2.05.2005, 09:03:28
Post #1





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




W folderze themes przechowuję foldery z szablonami. Wczytuję zawartość tego folderu i wyświetlam w selekcie. Wybieram skórę i zapisuję ustawienie. Napisałem skrypt, ale nie działa. Help!
  1. <?php
  2. function theme_set()
  3. {
  4. echo &#092;"<center><form action='\".$DefaultTheme.\".php' method='post'>\"
  5. .&#092;"<select name='DefaultTheme'><br>\";
  6. $handle=opendir('themes');
  7. while ($file = readdir($handle)) {
  8. if ( (!ereg(&#092;"[.]\",$file)) ) {
  9. $themelist .= &#092;"$file \";
  10. }
  11. }
  12. closedir($handle);
  13. $themelist = explode(&#092;" \", $themelist);
  14. sort($themelist);
  15. for ($i=0; $i < sizeof($themelist); $i++) {
  16. if($themelist[$i]!=&#092;"\") {
  17. echo &#092;"<option name='DefaultTheme' value='$themelist[$i]' \";
  18. if($themelist[$i]==$DefaultTheme) echo &#092;"selected\";
  19. echo &#092;">$themelist[$i]n\";
  20. }
  21. }
  22. echo &#092;"<center><input type='submit' value='Zapisz'></center></form>\";
  23. }
  24.  
  25. theme_set()
  26. ?>

Nie mogę poradzić sobie z wpisaniem tego w formularz i przeładowaniem. Help!


--------------------
Go to the top of the page
+Quote Post
Ociu
post 2.05.2005, 09:28:50
Post #2





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




  1. <?php
  2. function theme_set_form()
  3. {
  4. echo &#092;"<center><form action='set_theme.php' method='post'>\"
  5. .&#092;"<select name='DefaultTheme'><br />\";
  6. $handle=opendir('themes');
  7. while ($file = readdir($handle)) {
  8. if ( $file != '.' && $file != '..' && is_dir($file)) {
  9. echo &#092;"<option \".($file == $DefaultTheme) ? \"selected\" : \"\" .\" value=\".$file.\">\".$file.\"</option>\"; # wynikl blad, poprawiony
  10. }
  11. }
  12. closedir($handle);
  13.  
  14. echo &#092;"<center><input type='submit' value='Zapisz'></center></form>\";
  15. }
  16.  
  17. function set_theme($theme)
  18. {
  19. if($theme != null)
  20. {
  21. setcookie('theme', $theme, time()+60*60*24); # czy tam do bazy zapisujesz, jak wolisz
  22. }
  23. }
  24.  
  25. if(!isset($_COOKIE['theme']) OR empty($_POST['DefaultTheme']))
  26. {
  27. echo theme_set_form();
  28. } else {
  29. set_theme($_POST['DefaultTheme']);
  30. }
  31. ?>


Ten post edytował Ociu 2.05.2005, 12:37:37
Go to the top of the page
+Quote Post
Kshyhoo
post 2.05.2005, 09:59:20
Post #3





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Hmm, to nie działa sad.gif
Wolałbym przekazać do tego samego pliku...

Ten post edytował Kshyhoo 2.05.2005, 10:02:44


--------------------
Go to the top of the page
+Quote Post
Ociu
post 2.05.2005, 10:09:49
Post #4





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




tzn. co nie działa ?

error_reporting(E_ALL); - na poczatku daj
Go to the top of the page
+Quote Post
Kshyhoo
post 2.05.2005, 10:13:42
Post #5





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Interesuje mnie ten fragment:
  1. <?php
  2. function theme_set_form()
  3. {
  4. echo &#092;"<center><form action='set_theme.php' method='post'>\"
  5. .&#092;"<select name='DefaultTheme'><br />\";
  6. ?>

Jak to zrobić w obrębie jednego pliki?


--------------------
Go to the top of the page
+Quote Post
Ociu
post 2.05.2005, 10:16:48
Post #6





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




$_SERVER['PHP_SELF'];
Go to the top of the page
+Quote Post
-Guest-
post 2.05.2005, 12:11:03
Post #7





Goście







Chyba się poddam, nie mogę tego skręcić...
Go to the top of the page
+Quote Post
Ociu
post 2.05.2005, 12:40:51
Post #8





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




  1. <?php
  2. function theme_set_form()
  3. {
  4. echo &#092;"<center><form action='\".$_SERVER['PHP_SELF'].\"' method='post'>\"
  5. .&#092;"<select name='DefaultTheme'><br />\";
  6. ?>


W poprzednim kodzie wynikl blad w lini 10, poprawilem
Go to the top of the page
+Quote Post
Kshyhoo
post 2.05.2005, 13:11:19
Post #9





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Wyświetla mi formularz wyboru ale bez listy folderów. Na tym kończy wyświetlanie. tzn, nie wyświetla np. stopki.


--------------------
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 Wersja Lo-Fi Aktualny czas: 7.07.2025 - 23:05