So, I've a little system which generates pretty permalinks using htaccess.
PHP side of the things I handle in the following manner:
if (!$_GET) {
//
$page = "home";
$page_title = "General Site Title";
include ("template/index.php");
//
} else if ($_GET['page'] == "profile") {
//
if ($_GET['subpage']) {
//
header("HTTP/1.0 404 Not Found");
include ("template/404.php");
exit();
//
} else {
//
$page = "profile";
$page_title = "User Profile";
include ("template/profile.php");
//
}
//
} else if ($_GET['page'] == "words") {
//
if ($_GET['subpage']) {
//
header("HTTP/1.0 404 Not Found");
include ("template/404.php");
exit();
//
} else {
//
$page = "words";
$page_title = "Words Page";
include ("template/words.php");
}
//
} else if ($_GET['page'] == "contacts") {
//
if ($_GET['subpage']) {
//
header("HTTP/1.0 404 Not Found");
include ("template/404.php");
exit();
//
} else {
//
$page = "contacts";
$page_title = "User Contacts";
include ("template/contacts.php");
//
}
//
} else if ($_GET['page'] == "about") {
//
if ($_GET['subpage']) {
//
header("HTTP/1.0 404 Not Found");
include ("template/404.php");
exit();
//
} else {
//
$page = "about";
$page_title = "About Page";
include ("template/about.php");
//
}
//
} else if ($_GET['page'] == "verify") {
//
//
} else {
//
header("HTTP/1.0 404 Not Found");
include ("template/404.php");
exit();
//
}
As you can see there is allot of repeating code. How would you go about making this admin panel friendly? What I want to do is have an array of pages with data that will generate this if else statement. Is it possible?
Ideally something like this:
array("page" => "home", "page_title" => "blah", "template" => "index.php", "has_subpage" => false);
or should I stick to the way I'm doing things atm?
//lines first!casecould be an option.