selberbauer
Captain
- Registriert
- Juni 2009
- Beiträge
- 3.604
Hallo,
Ich übe gerade an einem Template System. Jetzt allerdings habe ich ein Problem, wenn ich auf unterseiten wechseln möchte, also der Aufruf über die Browserleiste mittels "localhost/index.php?section=contact" funktioniert, nur das wechseln auf der Seite selbst macht Probleme (Apache findet das Objekt nicht).
index.php
tmpl.php
tmpl-out.php
Ich übe gerade an einem Template System. Jetzt allerdings habe ich ein Problem, wenn ich auf unterseiten wechseln möchte, also der Aufruf über die Browserleiste mittels "localhost/index.php?section=contact" funktioniert, nur das wechseln auf der Seite selbst macht Probleme (Apache findet das Objekt nicht).
index.php
PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include('tmpl.php');
include('tmpl-out.php');
?>
tmpl.php
PHP:
<?php
$menu = array();
$menu[] = array('section' => 'home', 'title' => 'Home');
$menu[] = array('section' => 'about_us', 'title' => 'Über uns');
$menu[] = array('section' => 'services', 'title' => 'Dienstleistungen');
$menu[] = array('section' => 'reference', 'title' => 'Referenzen');
$menu[] = array('section' => 'tutorials', 'title' => 'Tutorials');
$menu[] = array('section' => 'downloads', 'title' => 'Downloads');
$menu[] = array('section' => 'contact', 'title' => 'Kontakt');
$current = $_GET['section'];
foreach ($menu as $m) {
$class = '';
if ($current == $m['section']) {
$class = ' class="current"';
}
$slice = "\t\t<li" . $class . '><a href="index?section=' . $m['section'] . '">' . $m['title'] . "</a></li>\r\n";
$all .= $slice;
}
if (!isset($_GET['section'])) {
$content = 'home.tpl';
} else {
$content = $_GET['section'] . '.tpl';
}
?>
tmpl-out.php
PHP:
<!DOCTYPE html>
<html>
<head>
<title>Tartaros</title>
<meta charset="utf-8" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="index, follow" />
<meta http-equiv="X-UA-Compatible" content="chrome-1" />
<link rel="stylesheet" media="all" href="style.css" />
</head>
<body>
<section>
<header>
<h1></h1>
<p></p>
</header>
<nav>
<ul>
<?php echo $all; ?>
</ul>
</nav>
<article>
<?php include($content); ?>
<article>
<footer>
<p>© 2011 <a href="index?section=contact">Impressum</a></p>
</footer>
</section>
</body>
</html>