diff --git a/Core/View.php b/Core/View.php index 0016bdf..8e251cf 100644 --- a/Core/View.php +++ b/Core/View.php @@ -29,7 +29,7 @@ public static function getDefaultViewPath() $router = App::getRouter(); $controllerDir = $router -> getRoute().DS.$router -> getController(); $templateName = $router -> getAction().'.html'; - return VIEW_PATH.DS.$controllerDir.DS.$templateName; + return $controllerDir.DS.$templateName; } public function render(){ diff --git a/Core/WebController.php b/Core/WebController.php index 35d53bc..73a43c5 100644 --- a/Core/WebController.php +++ b/Core/WebController.php @@ -39,6 +39,9 @@ function render($layout = null, $viewPath = null, &$data = null, &$meta = null) if (!$viewPath) $viewPath = View::getDefaultViewPath(); + //Relative to full path. + $viewPath = VIEW_PATH . DS . $viewPath; + //If no specific $data is not passed, use Controller's $this -> data instead if (!$data) $data = $this->data; @@ -49,26 +52,26 @@ function render($layout = null, $viewPath = null, &$data = null, &$meta = null) //Layout Paths - $layoutPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'layout.html'; + $layoutPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'layout.html'; $layoutHeaderPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'header.html'; $layoutFooterPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'footer.html'; - $layoutMetaPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'meta.html'; - $layoutAlertsDir = LAYOUT_VIEW_PATH . DS . $layout . DS . 'alerts'; + $layoutMetaPath = LAYOUT_VIEW_PATH . DS . $layout . DS . 'meta.html'; + $layoutAlertsDir = LAYOUT_VIEW_PATH . DS . $layout . DS . 'alerts'; //A dummy Var to be passed to views that doesn't use controller's data (as View's $data is passed by reference for optimization) $dummyVar = null; //Create Header / Footer / Meta / Body Views Instances - $bodyObj = new View($data, $viewPath); - $headerObj = new View($dummyVar, $layoutHeaderPath); - $footerObj = new View($dummyVar, $layoutFooterPath); - $metaObj = new View($dummyVar, $layoutMetaPath, $meta); + $bodyObj = new View($data, $viewPath); + $headerObj = new View($dummyVar, $layoutHeaderPath); + $footerObj = new View($dummyVar, $layoutFooterPath); + $metaObj = new View($dummyVar, $layoutMetaPath, $meta); //Do The Render $content = $bodyObj->render(); - $header = $headerObj->render(); - $footer = $footerObj->render(); - $meta = $metaObj->render(); + $header = $headerObj->render(); + $footer = $footerObj->render(); + $meta = $metaObj->render(); //Render Alerts if exits $alerts = "";