]> git.bts.cx Git - cx.git/blobdiff - cx/lib/template.php
Don't break when there's no hero image
[cx.git] / cx / lib / template.php
index e368a2ead46a74436e8e28e3daa50ce052369797..76e5318eba3477605dd9a069149db6bb10e46ce9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-function cx_template_render($class, $name, $variables = []) {
+function cx_template_render($class, $name, $variables = null) {
        global $cx_template_base, $cx_template_content;
        
        $base_template = null;
        global $cx_template_base, $cx_template_content;
        
        $base_template = null;
@@ -11,10 +11,12 @@ function cx_template_render($class, $name, $variables = []) {
                $path = join(DIRECTORY_SEPARATOR, $segments);
                
                $base_template = null;
                $path = join(DIRECTORY_SEPARATOR, $segments);
                
                $base_template = null;
+               $base_template_variables = null;
 
                $cx_template_base_previous = $cx_template_base;
 
                $cx_template_base_previous = $cx_template_base;
-               $cx_template_base = function($name) use (&$base_template ) {
+               $cx_template_base = function($name, $base_variables) use (&$base_template, &$base_template_variables) {
                        $base_template = $name;
                        $base_template = $name;
+                       $base_template_variables = $base_variables;
                };
 
                $cx_template_content_previous = $cx_template_content;
                };
 
                $cx_template_content_previous = $cx_template_content;
@@ -24,7 +26,10 @@ function cx_template_render($class, $name, $variables = []) {
 
                cx_require('lib', 'url.php'); // For templates
 
 
                cx_require('lib', 'url.php'); // For templates
 
-               extract($variables);
+               if ($variables != null) {
+                       extract($variables);
+               }
+
                ob_start();
                include($path);
                $output = ob_get_contents();
                ob_start();
                include($path);
                $output = ob_get_contents();
@@ -34,14 +39,15 @@ function cx_template_render($class, $name, $variables = []) {
                $cx_template_content = $cx_template_content_previous;
 
                $name = $base_template;
                $cx_template_content = $cx_template_content_previous;
 
                $name = $base_template;
+               $variables = $base_template_variables;
        }
 
        return $output;
 }
 
        }
 
        return $output;
 }
 
-function cx_template_base($name) {
+function cx_template_base($name, $variables = null) {
        global $cx_template_base;
        global $cx_template_base;
-       $cx_template_base($name);
+       $cx_template_base($name, $variables);
 }
 
 function cx_template_content() {
 }
 
 function cx_template_content() {