Worked out a class to easily include subpages/content and put the footer in a function
This commit is contained in:
35
content.php
Normal file
35
content.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
class Page
|
||||
{
|
||||
public $name, $filename;
|
||||
public static $contentFolder = "content/";
|
||||
|
||||
public function __construct($name, $filename)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
public function createPage()
|
||||
{
|
||||
include ("{$contentFolder}{$this->filename}.html");
|
||||
}
|
||||
|
||||
public function createMenuItem()
|
||||
{
|
||||
// Match just the name, without the .html, .php etc parc
|
||||
preg_match_all("/[a-z_\-0-9]*/i", $this->filename, $out);
|
||||
$bareFilename = $out[0][0];
|
||||
|
||||
// Print the menu item
|
||||
print ("<li class=\"link\"><a href=\"index.php?content={$bareFilename}\">" .
|
||||
$this->name . "</a></li>\n");
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user