Fix get_config() function #13.
This commit is contained in:
parent
c88f8e7967
commit
ac055a715a
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Override any of the default settings below:
|
// Override any of the default settings below:
|
||||||
|
|
||||||
$config['site_title'] = 'Pico'; // Site title
|
$config['site_title'] = 'Pico'; // Site title
|
||||||
$config['base_url'] = ''; // Override base URL (e.g. http://example.com)
|
$config['base_url'] = ''; // Override base URL (e.g. http://example.com)
|
||||||
$config['theme'] = 'default'; // Set the theme (defaults to "default")
|
$config['theme'] = 'default'; // Set the theme (defaults to "default")
|
||||||
$config['enable_cache'] = false; // Enable caching
|
$config['enable_cache'] = false; // Enable caching
|
||||||
|
|
||||||
To add a custom config setting:
|
// To add a custom config setting:
|
||||||
|
|
||||||
$config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme
|
$config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ define('LIB_DIR', ROOT_DIR .'lib/');
|
|||||||
define('THEMES_DIR', ROOT_DIR .'themes/');
|
define('THEMES_DIR', ROOT_DIR .'themes/');
|
||||||
define('CACHE_DIR', LIB_DIR .'cache/');
|
define('CACHE_DIR', LIB_DIR .'cache/');
|
||||||
|
|
||||||
require('config.php');
|
|
||||||
require(ROOT_DIR .'vendor/autoload.php');
|
require(ROOT_DIR .'vendor/autoload.php');
|
||||||
require(LIB_DIR .'markdown.php');
|
require(LIB_DIR .'markdown.php');
|
||||||
require(LIB_DIR .'pico.php');
|
require(LIB_DIR .'pico.php');
|
||||||
|
12
lib/pico.php
12
lib/pico.php
@ -105,11 +105,14 @@ class Pico {
|
|||||||
/**
|
/**
|
||||||
* Loads the config
|
* Loads the config
|
||||||
*
|
*
|
||||||
* @return array $defaults an array of config values
|
* @return array $config an array of config values
|
||||||
*/
|
*/
|
||||||
function get_config()
|
function get_config()
|
||||||
{
|
{
|
||||||
|
if(!file_exists(ROOT_DIR .'config.php')) return array();
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
require_once(ROOT_DIR .'config.php');
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'site_title' => 'Pico',
|
'site_title' => 'Pico',
|
||||||
@ -118,11 +121,10 @@ class Pico {
|
|||||||
'enable_cache' => false
|
'enable_cache' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($defaults as $key=>$val){
|
if(is_array($config)) $config = array_merge($defaults, $config);
|
||||||
if(isset($config[$key]) && $config[$key]) $defaults[$key] = $config[$key];
|
else $config = $defaults;
|
||||||
}
|
|
||||||
|
|
||||||
return $defaults;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user