Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][Smarty] Problem z template
Forum PHP.pl > Forum > Przedszkole
djjbenus
Witam,

chciałem oddzielić część templatek od innych ze względów tematycznych. Działają tylko dwie a z resztą mam problem bo wyskakuje że nie istnieje choć w folderze jest zadeklarowana i ma swoje "ciało"...

przedstawiam kod

admin.php
  1. <?php
  2. include("engine/database.class.php");
  3. databaseConnection();
  4.  
  5. require("libs/Smarty.class.php");
  6. $smarty = new Smarty;
  7.  
  8. //$smarty->force_compile = true;
  9. $smarty->debugging = false;
  10. $smarty->caching = false;
  11. $smarty->cache_lifetime = 120;
  12.  
  13. $smarty->addTemplateDir("templates/admin");
  14. $smarty->template_dir = "templates/admin";
  15. $smarty->compile_dir = "templates/admin/admin_c";
  16.  
  17. include("pages/admin.php");
  18.  
  19. $where = preg_replace("/[^a-zA-Z_0-9]/", "", $_GET["d"]);
  20.  
  21. if($where == "" )
  22. {
  23. $where = "start";
  24. }
  25.  
  26. $default = $pages_admin["default"];
  27.  
  28. $page = $pages_admin[$where];
  29.  
  30. if( !empty($page) )
  31. {
  32. $page = array_merge($default, $page);
  33.  
  34. $smarty->assign("content", $page);
  35. $smarty->display("admin.tpl");
  36. }
  37. else
  38. {
  39. //header("HTTP/1.1 404 Not Found");
  40. echo('404');
  41. }
  42. var_dump($where);
  43. unset($allowed_values);
  44. ?>


pages/admin.php
  1. <?php
  2.  
  3. $pages_admin = array (
  4. 'default' => array(
  5. 'link' => FALSE,
  6. 'template' => FALSE,
  7. 'title' => '',
  8. 'seo_title' => '',
  9. 'seo_description' => 'default description',
  10. 'seo_keywords' => 'default keywords',
  11. 'lang' => 'pl',
  12. 'redirect' => FALSE,
  13. 'response' => FALSE,
  14. 'article' => FALSE
  15. ),
  16.  
  17. //admin pages
  18. 'start' => array(
  19. 'link' => 'start',
  20. 'template' => 'start.tpl',
  21. 'title' => 'Mini CMS - Panel administracyjny',
  22. 'seo_title' => 'Mini CMS - Panel administracyjny',
  23. 'seo_description' => '',
  24. 'seo_keywords' => '',
  25. 'lang' => 'pl',
  26. ),
  27.  
  28. 'pages' => array(
  29. 'link' => 'pages',
  30. 'template' => 'pages.tpl',
  31. 'title' => 'pages',
  32. 'seo_title' => 'Mini CMS - zarządzanie stronami',
  33. 'seo_description' => '',
  34. 'seo_keywords' => '',
  35. 'lang' => 'pl',
  36. ),
  37.  
  38. 'works' => array(
  39. 'link' => 'works',
  40. 'template' => 'works.tpl',
  41. 'title' => 'works',
  42. 'seo_title' => 'Mini CMS - zarządzanie pracami',
  43. 'seo_description' => '',
  44. 'seo_keywords' => '',
  45. 'lang' => 'pl',
  46. ),
  47.  
  48. 'news' => array(
  49. 'link' => 'news',
  50. 'template' => 'news.tpl',
  51. 'title' => 'news',
  52. 'seo_title' => 'Mini CMS - zarządzanie newsami',
  53. 'seo_description' => '',
  54. 'seo_keywords' => '',
  55. 'lang' => 'pl',
  56. ),
  57.  
  58. 'test' => array(
  59. 'link' => 'test',
  60. 'template' => 'test.tpl',
  61. 'title' => 'test',
  62. 'seo_title' => 'strona testowa',
  63. 'seo_description' => '',
  64. 'seo_keywords' => 'praktyki',
  65. 'lang' => 'pl',
  66. )
  67. );
  68.  
  69. return false;
  70. ?>


admin.tpl
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3.  
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta http-equiv="Content-Language" content="pl" />
  7. <meta name="author" content="" />
  8. <meta name="reply-to" content="" />
  9. <meta name="date" content="2014/01/10" />
  10. <meta name="robots" content="index,follow" />
  11. <meta name="distribution" content="global" />
  12.  
  13. <meta http-equiv="Content-Style-Type" content="text/css" />
  14. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  15. <link href="templates/admin/images/flavicon.png" rel="shortcut icon" />
  16.  
  17. <link rel="stylesheet" href="templates/style/admin.css" type="text/css" />
  18.  
  19. <!--<script type="text/javascript" src="jq/admin.js"></script>-->
  20.  
  21. <title>{$content.seo_title}</title>
  22. <meta name="keywords" content="{$content.seo_keywords}" />
  23. <meta name="description" content="{$content.seo_description}" />
  24.  
  25. </head>
  26.  
  27. <body>
  28. <div id="wrapper">
  29. <div id="container">
  30.  
  31. <ul>
  32. <li><a href="pages.html">strony</a></li>
  33. <li><a href="works.html">prace</a></li>
  34. <li><a href="news.html">news</a></li>
  35. </ul>
  36. <br />
  37. {include file=$content.template}
  38.  
  39. </div><!-- #container# -->
  40. </div><!-- #wrapper# -->
  41. </body>
  42. </html>


Jest ktoś kto widzi błąd?
nospor
No i jaka ci dziala a jaka nie dziala?
djjbenus
Wpisując adres folder/admin.php pokazuje templatkę admin z ciałem start, w której są linki do następnych ale wcale nie działają bo piszę że taka templatka nie istnieje.

Doszedłem po wielu godzinach że jakby szło przekierowanie w tym samym folderze na index.php a admin.php już wypiera... Jak to można naprawić?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.