Skip to content

Commit

Permalink
Added the option for theme options.
Browse files Browse the repository at this point in the history
Based on issue anchorcms#58
  • Loading branch information
Baylor Rae committed Feb 16, 2012
1 parent 30bbdc1 commit 89462f5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions system/classes/template.php
Expand Up @@ -29,6 +29,11 @@ private static function parse($file, $data) {
public static function render($template, $data = array()) {
// get default theme
$theme = Config::get('metadata.theme');

/*
Load Theme Config
*/
ThemeConfig::load();

// load global theming functions but not for the admin template
if(strpos(static::$path, 'system/admin/theme') === false) {
Expand All @@ -41,6 +46,7 @@ public static function render($template, $data = array()) {
require PATH . 'system/functions/posts.php';
require PATH . 'system/functions/search.php';
require PATH . 'system/functions/users.php';
require PATH . 'system/functions/themeconfig.php';
}

// load theme functions
Expand Down
29 changes: 29 additions & 0 deletions system/classes/themeconfig.php
@@ -0,0 +1,29 @@
<?php defined('IN_CMS') or die('No direct access allowed.');

/*
An extension of the Config class
designed to focus specifically on configuring themes
*/
class ThemeConfig extends Config {

/*
has to be public so Config can read it
*/
public static $items = array();

/*
* Allows a default config file
* to be created within the theme directory
*
* @author Baylor Rae'
* @package AnchorCMS
* @since 0.5
*/
public static function load() {
$theme_config_file = Template::path() . 'config.php';
if( file_exists($theme_config_file) ) {
static::$items = require $theme_config_file;
}
}

}
14 changes: 14 additions & 0 deletions system/functions/themeconfig.php
@@ -0,0 +1,14 @@
<?php defined('IN_CMS') or die('No direct access allowed.');

/*
Functions for theme configuration
*/
function set_theme_options(array $options) {

foreach( $options as $option => $value )
ThemeConfig::set($option, $value);
}

function theme_option($option, $default_value = false) {
return ThemeConfig::get($option, $default_value);
}

0 comments on commit 89462f5

Please sign in to comment.