]> git.bts.cx Git - garden.git/blobdiff - garden.php
Added template fallback support
[garden.git] / garden.php
index 99cb0123ac8f07091403252717e70e4058d05b80..6035ee8dde8192d670e60058f0b082b9d2700f09 100644 (file)
@@ -260,7 +260,11 @@ function garden_template_render($name, $variables = null) {
        $output = '';
        while ($name != null) {
                $path = garden_path(GARDEN_TEMPLATE_DIR, $name . '.php');
-               
+
+               if (file_exists($path) == false) {
+                       $path = garden_path(GARDEN_FALLBACK_TEMPLATE_DIR, $name . '.php');
+               }
+
                $base_template = null;
                $base_template_variables = null;
 
@@ -312,8 +316,6 @@ function garden_site_url(...$url_segments) {
        return GARDEN_SITE_BASE_URL . garden_url(...$url_segments);
 }
 
-
-
 ///////////////////////////////////////////////////////////////////////////////
 // Images
 ///////////////////////////////////////////////////////////////////////////////
@@ -605,6 +607,8 @@ function garden() {
 assert(extension_loaded('imagick'), 'Needs Imagick');
 assert($argc >= 2, 'Please provide configuration file');
 
+define('GARDEN_FALLBACK_TEMPLATE_DIR', garden_path(__DIR__, 'templates'));
+
 // First parameter needs to be the configuration php
 $config_file = $argv[1];