Changes to add recent news to the Recent Posts Theme for the front page
This commit is contained in:
parent
501f2694ff
commit
bea631d3f5
|
@ -64,12 +64,21 @@
|
||||||
'comment' => '(eg. "recent.css" - see templates/themes/recent for details)'
|
'comment' => '(eg. "recent.css" - see templates/themes/recent for details)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => '# of recent news',
|
||||||
|
'name' => 'limit_news',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => '1',
|
||||||
|
'comment' => '(maximum news to display)'
|
||||||
|
);
|
||||||
// Unique function name for building everything
|
// Unique function name for building everything
|
||||||
$theme['build_function'] = 'recentposts_build';
|
$theme['build_function'] = 'recentposts_build';
|
||||||
$theme['install_callback'] = 'recentposts_install';
|
$theme['install_callback'] = 'recentposts_install';
|
||||||
|
|
||||||
if (!function_exists('recentposts_install')) {
|
if (!function_exists('recentposts_install')) {
|
||||||
function recentposts_install($settings) {
|
function recentposts_install($settings) {
|
||||||
|
if (!is_numeric($settings['limit_news']) || $settings['limit_news'] < 0)
|
||||||
|
return Array(false, '<strong>' . utf8tohtml($settings['limit_news']) . '</strong> is not a non-negative integer.');
|
||||||
if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0)
|
if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0)
|
||||||
return Array(false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.');
|
return Array(false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.');
|
||||||
if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0)
|
if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0)
|
||||||
|
|
|
@ -51,7 +51,7 @@ body
|
||||||
color: #7fdd57;
|
color: #7fdd57;
|
||||||
border: 0px solid #006;
|
border: 0px solid #006;
|
||||||
float: right;
|
float: right;
|
||||||
width: 50%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.box h2 {
|
.box h2 {
|
||||||
|
|
|
@ -33,7 +33,24 @@
|
||||||
<div class="ban" id="global2"> <h2>CYBERPUNK IS DUCK</h2> Pour out the Soykaf, lurk, and read the <a href="https://lainchan.org/rules">rules</a> before posting! </div>
|
<div class="ban" id="global2"> <h2>CYBERPUNK IS DUCK</h2> Pour out the Soykaf, lurk, and read the <a href="https://lainchan.org/rules">rules</a> before posting! </div>
|
||||||
<center> <img alt="mascot" class="lain_banner" src="static/duck.png"></center>
|
<center> <img alt="mascot" class="lain_banner" src="static/duck.png"></center>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="ban" id="global3">
|
||||||
|
<h2>Latest News</h2>
|
||||||
|
{% if recent_news|count == 0 %}
|
||||||
|
<p style="text-align:center" class="unimportant">(No news to show.)</p>
|
||||||
|
{% else %}
|
||||||
|
{% for entry in recent_news %}
|
||||||
|
<h4 id="{{ entry.id }}">
|
||||||
|
{% if entry.subject %}
|
||||||
|
{{ entry.subject }}
|
||||||
|
{% else %}
|
||||||
|
<em>no subject</em>
|
||||||
|
{% endif %}
|
||||||
|
<span class="unimportant"> — by {{ entry.name }} at {{ entry.time|date(config.post_date, config.timezone) }}</span>
|
||||||
|
</h4>
|
||||||
|
<p>{{ entry.body }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
<div class="ban" id="global">
|
<div class="ban" id="global">
|
||||||
<div class="box left">
|
<div class="box left">
|
||||||
<h2>Recent Images</h2>
|
<h2>Recent Images</h2>
|
||||||
|
@ -59,6 +76,7 @@
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box right">
|
<div class="box right">
|
||||||
<h2>Stats</h2>
|
<h2>Stats</h2>
|
||||||
|
|
|
@ -147,13 +147,17 @@
|
||||||
$stats['active_content'] += array_sum($matches[1]);
|
$stats['active_content'] += array_sum($matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query = query("SELECT * FROM ``news`` ORDER BY `time` DESC" . ($settings['limit_news'] ? ' LIMIT ' . $settings['limit_news'] : '')) or error(db_error());
|
||||||
|
$recent_news = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return Element('themes/recent/recent.html', Array(
|
return Element('themes/recent/recent.html', Array(
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'boardlist' => createBoardlist(),
|
'boardlist' => createBoardlist(),
|
||||||
'recent_images' => $recent_images,
|
'recent_images' => $recent_images,
|
||||||
'recent_posts' => $recent_posts,
|
'recent_posts' => $recent_posts,
|
||||||
'stats' => $stats
|
'stats' => $stats,
|
||||||
|
'recent_news' => $recent_news,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue