Jump to content

Kryllster

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Kryllster

  1. I believe it would be the PAGE_DIR which as it is only allows for 1 set directory I Have several of these as controllers in this project but I want to use just 1 controller instead of several. Does that help??
  2. I have this script as my index.php <?php include_once "templates/header.php"; include_once "templates/website/navi1.php"; define("PAGE_DIR", dirname(__FILE__) . "/templates/website"); require_once "templates/FrontController.php"; FrontController::createInstance()->dispatch(); include_once "templates/footer.php"; ?> And I have this as my frontcontroller: <?php class FrontController { public static function createInstance() { if (!defined("PAGE_DIR")) { exit("Critical error: Cannot proceed without PAGE_DIR."); } $instance = new self(); return $instance; } public function dispatch() { $page = !empty($_GET["page"]) ? $_GET["page"] : "main"; $class = ucfirst($page) . "page"; //e.g. pages/home/HomeActions.php $file = PAGE_DIR . "/" . $page . ".php"; if (!is_file($file)) { exit("Page not found"); } require_once $file; } } ?> Both of these I had gotten off the internet and it does work however its pretty limited I need to go into sub folders and such but I'm stuck as how to go about this a link or tutorial would be nice or just some pointers. Thanks,
  3. I am in need of some articles and examples of a FrontController that will handle multiple directories.Coul someone point me in the right direction? Thanks,
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.