Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Tytuł strony inny na każdej stronie.
GoldeNx3
post
Post #1





Grupa: Zarejestrowani
Postów: 228
Pomógł: 1
Dołączył: 24.12.2010

Ostrzeżenie: (0%)
-----


Witam! Mam tak napisaną stronę:

  1. <html>
  2. <head>
  3. <title>Tytuł</title>
  4.  
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  6. <meta name="description" content="desc" />
  7. <meta name="keywords" content="key" />
  8.  
  9. <link rel="stylesheet" href="style.css" type="text/css" />
  10. </head>
  11.  
  12. <body>
  13.  
  14. <?php
  15. define('DIR', 'pages/');
  16.  
  17. switch($_GET['mdl'])
  18. {
  19. case $_GET['mdl']:
  20. if(file_exists(DIR . $_GET['mdl'] . '.php')){
  21. include(DIR . $_GET['mdl'] . '.php');
  22. }
  23. break;
  24. }
  25. ?>
  26.  
  27. </body>
  28. </html>


Oczywiście usunąłem co nie potrzebne.
Ale tutaj mam tytuł strony tylko jeden. ("Tytuł")
A co, jak w zależności od strony chciałbym dać inny tytuł strony? To jak?

Ten post edytował GoldeNx3 13.04.2012, 14:48:02
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
crocodillo
post
Post #2





Grupa: Zarejestrowani
Postów: 215
Pomógł: 44
Dołączył: 31.07.2011
Skąd: wrocław

Ostrzeżenie: (0%)
-----


Na podstawie kodu z Twojego postu to można zrobić coś takiego:
  1. <?php
  2.  
  3.  
  4. define('DIR', 'pages/');
  5.  
  6. if(file_exists(DIR . $_GET['mdl'] . '.php')){
  7. include(DIR . $_GET['mdl'] . '.php');
  8. }
  9.  
  10. $buffer = ob_get_clean();
  11.  
  12. ?>
  13.  
  14. <html>
  15. <head>
  16. <title><?php echo isset($title) ? $title : 'Tytuł strony'; ?></title>
  17.  
  18. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  19. <meta name="description" content="desc" />
  20. <meta name="keywords" content="key" />
  21.  
  22. <link rel="stylesheet" href="style.css" type="text/css" />
  23. </head>
  24.  
  25. <body>
  26.  
  27. <?php
  28. echo $buffer;
  29. ?>
  30.  
  31. </body>
  32. </html>

Tytuł zapisujesz do zmiennej $title w dołączanych plikach
Go to the top of the page
+Quote Post

Posty w temacie


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: 15.10.2025 - 03:14