« Project home page

phpSQLiteCMS Forum

Back to the forum index
Open in thread

News Headlines on Index Page (Technics)

by Ryan, Friday, June 11, 2010, 11:26 (89 days ago) @ Ryan

I love this thing!

Anyway, to save time for those getting started...

set content_function to 1 in Administration → Settings → Advanced settings

Throw the php function below into includes/functions.inc.php and edit as necessary

--------------------------------------
function get_latest_news_headlines($limit) {
$dbr = Database::$content->query("
SELECT page, title, time FROM ".Database::$db_settings['pages_table']." WHERE sections = 'news' AND content_type = '' AND status > 0 AND NOT type = 'news' ORDER BY time DESC LIMIT " . $limit);
$headlines = '';
while ( $row = $dbr->fetch() ) {$headlines .= "<li><a href=\"" . $row['page'] . "\">" . $row['title'] . "</a><span class=\"timestamp\"> " . date("l, M j, Y",$row['time']) . "</span></li>";}
return $headlines;
}
--------------------------------------

and add the following into the index page.

<ul id="headlines">
[function:get_latest_news_headlines(5)]
</ul>

 

Complete thread:

 RSS Feed of thread

192 Postings in 89 Threads, 63 registered users, 6 users online (0 registered, 6 guests)
Forum time: 2010-09-08, 15:20
RSS Postings  RSS Threads | Contact
powered by my little forum