I'm relatively dense when it comes to learning new material, so I appreciate your help and patience.
I'm not following what the purpose of the switch does in your code? It also looks like the include would only work if the file also existed in the root folder. But, maybe this is just a basic example?
Does this script still work for a structure like:
/root/product1/index.php?page=topic1
/root/product1/index.php?page=topic2
/root/product1/index.php?page=topic3
/root/product2/index.php?page=topic1
/root/product2/index.php?page=topic2
/root/product2/index.php?page=topic3
/root/product3/index.php?page=topic1
/root/product3/index.php?page=topic2
/root/product3/index.php?page=topic3
The topic pages are static content pages. They are not getting their content from a database. Below is the code for an index page.
$allowedPages = array('default', 'detail', 'list');
$page = (isset($_GET['page']) && $_GET['page'] != '' && in_array($_GET['page'], $allowedPages)) ? $_GET['page'] : '';
switch ($page) {
case 'list' :
$myid = (!isset($_SESSION['myId']) ? header('Location: /store/account/index.php') : (int)$_SESSION['myId']);
$catId = (!isset($_GET['catId']) ? '0' : (int)$_GET['catId']);
$content = 'list.php';
$pageTitle = 'PRODUCTS';
break;
case 'detail' :
$myid = (!isset($_SESSION['myId']) ? header('Location: /store/account/index.php') : (int)$_SESSION['myId']);
$productId = (!isset($_GET['productId']) ? '1' : (int)$_GET['productId']);
$catId = (!isset($_GET['catId']) ? '1' : (int)$_GET['catId']);
$content = 'detail.php';
$pageTitle = 'DETAILS';
break;
default :
$footer = 'ON';
$myid = (!isset($_SESSION['myId']) ? header('Location: /store/account/index.php') : (int)$_SESSION['myId']);
$catId = (!isset($_GET['catId']) ? '0' : (int)$_GET['catId']);
$content = 'default.php';
$pageTitle = 'STORE';
require_once(TEMPLATES_PATH . '/content.php');
}
The $content variable includes a page like:
require_once(LIBRARY_PATH . '/doProcess.php');
require_once(TEMPLATES_PATH . '/header.php');
require_once($content);
require_once(TEMPLATES_PATH . '/footer.php');