瀏覽代碼

added check if template exists, and aff fallback to index.html

Frank Nägler 11 年之前
父節點
當前提交
a5e21c704c
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      lib/pico.php

+ 4 - 0
lib/pico.php

@@ -100,6 +100,10 @@ class Pico {
 		);
 		);
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig));
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig));
 		$template = (isset($meta['template']) && strlen($meta['template']) > 0) ? $meta['template'] : 'index';
 		$template = (isset($meta['template']) && strlen($meta['template']) > 0) ? $meta['template'] : 'index';
+		if (!file_exists(THEMES_DIR . $settings['theme'] . "/{$template}.html")) {
+			// fallback to index.html if template not exists...
+			$template = 'index';
+		}
 		$output = $twig->render("{$template}.html", $twig_vars);
 		$output = $twig->render("{$template}.html", $twig_vars);
 		$this->run_hooks('after_render', array(&$output));
 		$this->run_hooks('after_render', array(&$output));
 		echo $output;
 		echo $output;