Pcfr43k
06-24-2010, 08:42 PM
I have a PHP file that includes 2 other PHP files.
One creates a menu, the other displays content from files.
Now I'm trying to set an array with the menu and read this array with the displayer.
index:
<?php
include("settings.php");
$p="";
echo "<html><head><title>".$company['name']."</title>";
echo "<link rel='stylesheet' type='text/css' href=".$theme['file']." />";
echo "</head><body>";
echo "<div id='menu'>";
include("menu.tpl");
echo "</div>";
echo "<div id='content'>";
include("content.tpl");
echo "</div>";
echo "</body>";
?>
Menu:
<?php
//Open directory
$dir = opendir("pages");
//List files in directory
while (($file = readdir($dir)) !== false) {
//Files only filter
if ($file != '.' && $file != '..')
$file2 = $file;
//Filename only filter
$info = pathinfo($file2);
$filename = basename($file2,'.'.$info['extension']);
//Empty result filter
if ($file2 != '')
//Display link with filename
echo "<ul id='navlinks'><li><A HREF=?p=" . $filename . ">" . $filename . "</A></li></ul>";
}
closedir($dir);
?>
Display:
<?php
if (!isset($p)){
$c=file_get_contents("pages/Start.html");
} else {
$c=file_get_contents("pages/'.$p.'.html");
}
echo $c;
?>
I get the Start page, but setting another page shows also the Start page.
What am I doing wrong here?
One creates a menu, the other displays content from files.
Now I'm trying to set an array with the menu and read this array with the displayer.
index:
<?php
include("settings.php");
$p="";
echo "<html><head><title>".$company['name']."</title>";
echo "<link rel='stylesheet' type='text/css' href=".$theme['file']." />";
echo "</head><body>";
echo "<div id='menu'>";
include("menu.tpl");
echo "</div>";
echo "<div id='content'>";
include("content.tpl");
echo "</div>";
echo "</body>";
?>
Menu:
<?php
//Open directory
$dir = opendir("pages");
//List files in directory
while (($file = readdir($dir)) !== false) {
//Files only filter
if ($file != '.' && $file != '..')
$file2 = $file;
//Filename only filter
$info = pathinfo($file2);
$filename = basename($file2,'.'.$info['extension']);
//Empty result filter
if ($file2 != '')
//Display link with filename
echo "<ul id='navlinks'><li><A HREF=?p=" . $filename . ">" . $filename . "</A></li></ul>";
}
closedir($dir);
?>
Display:
<?php
if (!isset($p)){
$c=file_get_contents("pages/Start.html");
} else {
$c=file_get_contents("pages/'.$p.'.html");
}
echo $c;
?>
I get the Start page, but setting another page shows also the Start page.
What am I doing wrong here?