first frontend
[phinde.git] / www / www-header.php
diff --git a/www/www-header.php b/www/www-header.php
new file mode 100644 (file)
index 0000000..60adacf
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace phinde;
+require_once __DIR__ . '/../src/init.php';
+
+\Twig_Autoloader::register();
+$GLOBALS['twig'] = new \Twig_Environment(
+    new \Twig_Loader_Filesystem(__DIR__ . '/../data/templates'),
+    array(
+        //'cache' => '/path/to/compilation_cache',
+        'debug' => true
+    )
+);
+$GLOBALS['twig']->addExtension(new \Twig_Extension_Debug());
+
+
+function render($tplname, $vars = array(), $return = false)
+{
+    if (!isset($vars['htmlhelper'])) {
+        //$vars['htmlhelper'] = new HtmlHelper();
+    }
+    $vars['apptitle'] = 'cweiske.de search';
+
+    $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
+    if ($return) {
+        return $template->render($vars);
+    } else {
+        echo $template->render($vars);
+    }
+}
+?>