engine = new Engine($base); if (!is_dir($theme)) { $theme = $base; } $this->engine->addFolder('theme', $theme, true); $this->registerFunctions(); } public function render($name, array $data = array()) { $this->engine->addData([ 'index' => utf8_encode($data['params']['base_page'] . $data['params']['index']->value), 'base_url' => $data['params']['base_url'], 'base_page' => $data['params']['base_page'], 'page' => $data['page'], 'params' => $data['params'], //'homepage' => $data['params']['homepage'], //'project_title' => utf8_encode($data['params']['title']), 'tree' => $data['params']['tree'], //'entry_page' => $data['page']['entry_page'], ]); return $this->engine->render($name, $data); } protected function registerFunctions() { $this->engine->registerFunction('get_navigation', function($tree, $path, $current_url, $base_page, $mode) { $nav = '
'; return $nav; }); $this->engine->registerFunction('get_breadcrumb_title', function($page, $base_page) { $title = ''; $breadcrumb_trail = $page['breadcrumb_trail']; $separator = $this->getSeparator($page['breadcrumb_separator']); foreach ($breadcrumb_trail as $key => $value) { $title .= '' . $key . '' . $separator; } if ($page['filename'] === 'index' || $page['filename'] === '_index') { if ($page['title'] != '') { $title = substr($title, 0, -1 * strlen($separator)); } } else { $title .= '' . $page['title'] . ''; } return $title; }); } private function buildNavigation($tree, $path, $current_url, $base_page, $mode) { $nav = ''; foreach ($tree->value as $node) { $url = $node->getUri(); if ($node instanceof \Todaymade\Daux\Tree\Content) { if ($node->value === 'index') { continue; } $nav .= '