From 89184a813497c76a0dbadd738f3e9269605fb962 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Fri, 22 Aug 2014 14:28:19 +0100 Subject: [PATCH] Implement `TemplateGlobalProvider` on `SiteConfig` Seeing as the `SiteConfig` is a site wide and "global" object, it makes sense to have it universally available to the templates --- code/model/SiteConfig.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/model/SiteConfig.php b/code/model/SiteConfig.php index ef4b671b..01cfc00a 100644 --- a/code/model/SiteConfig.php +++ b/code/model/SiteConfig.php @@ -17,7 +17,7 @@ * @author Tom Rix * @package cms */ -class SiteConfig extends DataObject implements PermissionProvider { +class SiteConfig extends DataObject implements PermissionProvider, TemplateGlobalProvider { private static $db = array( "Title" => "Varchar(255)", "Tagline" => "Varchar(255)", @@ -309,4 +309,14 @@ class SiteConfig extends DataObject implements PermissionProvider { return false; } + + /** + * Add $SiteConfig to all SSViewers + */ + public static function get_template_global_variables() { + return array( + 'SiteConfig' => 'current_site_config', + ); + } + }