"# of recent entries" setting adding to basic theme
This commit is contained in:
parent
658a7b4379
commit
5c847c75ac
@ -11,7 +11,7 @@
|
||||
$theme['config'] = Array();
|
||||
|
||||
$theme['config'][] = Array(
|
||||
'title' => 'Title',
|
||||
'title' => 'Site title',
|
||||
'name' => 'title',
|
||||
'type' => 'text'
|
||||
);
|
||||
@ -19,9 +19,35 @@
|
||||
$theme['config'][] = Array(
|
||||
'title' => 'Slogan',
|
||||
'name' => 'subtitle',
|
||||
'type' => 'text'
|
||||
'type' => 'text',
|
||||
'comment' => '(optional)'
|
||||
);
|
||||
|
||||
$theme['config'][] = Array(
|
||||
'title' => 'File',
|
||||
'name' => 'file',
|
||||
'type' => 'text',
|
||||
'default' => $config['file_index'],
|
||||
'comment' => '(eg. "index.html")'
|
||||
);
|
||||
|
||||
$theme['config'][] = Array(
|
||||
'title' => '# of recent entries',
|
||||
'name' => 'no_recent',
|
||||
'type' => 'text',
|
||||
'default' => 0,
|
||||
'size' => 3,
|
||||
'comment' => '(number of recent news entries to display; "0" is infinite)'
|
||||
);
|
||||
|
||||
// Unique function name for building everything
|
||||
$theme['build_function'] = 'basic_build';
|
||||
?>
|
||||
$theme['install_callback'] = 'build_install';
|
||||
|
||||
if(!function_exists('build_install')) {
|
||||
function build_install($settings) {
|
||||
if(!is_numeric($settings['no_recent']) || $settings['no_recent'] < 0)
|
||||
return Array(false, '<strong>' . $settings['no_recent'] . '</strong> is not a non-negative integer.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,16 @@
|
||||
global $config;
|
||||
|
||||
if($action == 'all' || $action == 'news')
|
||||
file_write($config['dir']['home'] . $config['file_index'], Basic::homepage($settings));
|
||||
file_write($config['dir']['home'] . $settings['file'], Basic::homepage($settings));
|
||||
}
|
||||
|
||||
// Build news page
|
||||
public static function homepage($settings) {
|
||||
global $config;
|
||||
|
||||
$query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error());
|
||||
$settings['no_recent'] = (int) $settings['no_recent'];
|
||||
|
||||
$query = query("SELECT * FROM `news` ORDER BY `time` DESC" . ($settings['no_recent'] ? ' LIMIT ' . $settings['no_recent'] : '')) or error(db_error());
|
||||
$news = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return Element('themes/basic/index.html', Array(
|
||||
|
Loading…
Reference in New Issue
Block a user