<?php $basecoat->view->add('title', '404: Not Found'); header('HTTP/1.0 404 Not Found'); $content = new \Basecoat\View(); $content->add('requested_page', $this->requested_route); // Add route content to page $content->processTemplate($basecoat->view->templates_path . $this->current['template']); $content->addToView($basecoat->view); unset($content);
<?php $basecoat->view->add('title', 'Introduction'); $content = new \Basecoat\View(); // Add route content to page $content->processTemplate($basecoat->view->templates_path . $basecoat->routing->current['template']); $content->addToView($basecoat->view); unset($content); $basecoat->routing->runNext();
// Example on how to get a new db instance $newDdb = DB::getServerInstance('slave'); */ // // Register layout so they can referenced by name $bc->view->setLayouts(array('basic' => $path_layouts . 'basic.php', 'json' => $path_layouts . 'json.tpl.php', 'dialog' => $path_layouts . 'dialog.php')); $bc->view->setLayout('basic'); // // Register global values with view $bc->view->add('sitename', 'Basecoat'); // // Set path to template files $bc->view->setTemplatesPath($path_templates); // // Add a hook before output to process common page elements $bc->addBeforeRender(function () use($bc) { $content = new \Basecoat\View(); $content->processTemplate($bc->view->templates_path . 'common/header.php'); $content->processTemplate($bc->view->templates_path . 'common/footer.php'); $content->addToView($bc->view); $bc->view->add('requested_route', $bc->routing->requested_route); }); // // Define routes $routes = array('static' => array('file' => $path_routes . 'static.php', 'cacheable' => array('expires' => '20 minutes')), '/' => array('file' => $path_routes . 'index.php', 'template' => 'index.tpl.php'), 'login' => array('file' => $path_routes . 'login.php', 'template' => 'login.php', 'require_secure' => 1), 'logout' => array('file' => $path_routes . 'logout.php'), 'data' => array('file' => $path_routes . 'data.php', 'data_only' => 1), 'log' => array('file' => $path_routes . 'log_action.php', 'data_only' => 1), 'configuration' => array('file' => $path_routes . 'configuration.php', 'template' => 'configuration.tpl.php'), 'routes' => array('file' => $path_routes . 'routing.php', 'template' => 'routing.tpl.php'), 'content' => array('file' => $path_routes . 'content.php', 'template' => 'content.tpl.php'), 'database' => array('file' => $path_routes . 'database.php', 'template' => 'database.tpl.php', 'require_login' => false), 'messages' => array('file' => $path_routes . 'messages.php', 'template' => 'messaging.tpl.php'), 'examples' => array('file' => $path_routes . 'examples.php', 'template' => 'examples.tpl.php'), 'json' => array('file' => $path_routes . 'json.php', 'layout' => 'json'), 'login' => array('file' => $path_routes . 'login.php', 'template' => 'login.tpl.php'), 'hello' => array('function' => function () { exit('Hello World!'); }), 'undefined' => array('file' => $path_routes . '404.php', 'template' => '404.tpl.php', 'layout' => 'basic', 'data_only' => 1)); $bc->routing->setRoutes($routes); // // Process the request echo $bc->processRequest();
if (isset($_POST['task_id'])) { // Save task if ($_POST['task_id'] == 'new') { $task_data['created_on'] = date('Y-m-d'); $result = $tasks->save($_POST['task_data']); } else { $result = $tasks->update($_POST['task_id'], $_POST['task_data']); } if ($result <= 0) { $basecoat->messages->error('Error saving task: ' . Core::$db->errorMsg); } else { $basecoat->messages->info('The task has been saved, now do it!'); header('Location: ./'); } } $content = new \Basecoat\View(); $content->add('status_opts', $tasks->getStatusOpts()); $content->add('category_opts', $tasks->getCategoryOpts()); if ($_GET['id'] != 'new') { // Retrieve task $task_data = $tasks->get($_GET['id']); if (!is_array($task_data)) { $basecoat->messages->error('Invalid Task ID specified, entering a new Task'); $_GET['task_id'] = 'new'; } } if ($_GET['id'] == 'new') { $task_data = array('task' => '', 'description' => '', 'category_id' => $tasks->default_category_id, 'status_id' => $tasks->default_status_id); } $task_data['task_id'] = $_GET['id']; $content->multiadd($task_data);
<?php $content = new \Basecoat\View(); $content->add('title', '404: Not Found'); header('HTTP/1.0 404 Not Found'); $content->add('requested_page', $basecoat->routing->requested_url); // Add route content to page $content->processTemplate($basecoat->view->templates_path . $basecoat->routing->current['template']); $content->addToView($basecoat->view); unset($content);
<?php $content = new \Basecoat\View(); $tpl = file_get_contents($basecoat->view->templates_path . $basecoat->routing->current['template']); $content->parseBlocks($tpl); // Add route content to page $content->addToView($basecoat->view); unset($content);