diff --git a/index.php b/index.php index 1cd7cd8501a84f6d38179668607cada29d2bcc8a..ebb0c762809f9d12e3750894e989761889f4679c 100644 --- a/index.php +++ b/index.php @@ -2,14 +2,25 @@ // This file is the main controller include 'template/header.php'; - // TODO: Handle url to detect wich controller to call + // Handle url + $url = explode("/", $_SERVER['PHP_SELF']); + if(isset($url[3])) { + $page = $url[3]; + } else { + $page = "index"; + } + if(isset($url[4])) { + $action = $url[4]; + } else { + $action = ""; + } + if(!file_exists('controller/'.$page.'.php')) { $page = "404"; } // Show the menu, the previous part have set wich page we are on to set the "active" class in menu include 'template/menu.php'; - // TODO: Call the correct controller - include 'controller/index.php'; + // Call the correct controller + include 'controller/'.$page.'.php'; // Show the footer - include 'template/footer.php'; -?> + include 'template/footer.php'; \ No newline at end of file diff --git a/view/index.php b/view/index.php index b439f75af279ed9e648775a81c7d3b2a532af44b..4c6222c2df9822aef197a943d7bf38185d6373e0 100644 --- a/view/index.php +++ b/view/index.php @@ -3,6 +3,11 @@ <div class="page-header"> <h1>Sticky footer with fixed navbar</h1> </div> + <pre> + <?php print_r($url); ?> + <pre> + <?php print_r($_SERVER); ?> + </pre> <p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added with <code>padding-top: 60px;</code> on the <code>body > .container</code>.</p> <p>Back to <a href="../sticky-footer">the default sticky footer</a> minus the navbar.</p> </div> \ No newline at end of file