Example #1
0
 function create_page($file_path)
 {
     # return a 404 if a matching folder doesn't exist
     if (!file_exists($file_path)) {
         throw new Exception('404');
     }
     # register global for the path to the page which is currently being viewed
     global $current_page_file_path;
     $current_page_file_path = $file_path;
     # register global for the template for the page which is currently being viewed
     global $current_page_template_file;
     $template_name = Page::template_name($file_path);
     $current_page_template_file = Page::template_file($template_name);
     # error out if template file doesn't exist (or glob returns an error)
     if (empty($template_name)) {
         throw new Exception('404');
     }
     if (!$current_page_template_file) {
         throw new Exception('A template named \'' . $template_name . '\' could not be found in the \'/templates\' folder');
     }
     # render page
     $this->render($file_path, $current_page_template_file);
 }