« Project home page

phpSQLiteCMS Forum

Back to the forum index
Open in thread

News Headlines on Index Page (using simple news) (Technics)

by Ryan, Wednesday, June 23, 2010, 18:38 (77 days ago) @ Ryan
edited by Ryan, Wednesday, June 23, 2010, 19:26

Here's a function for grabbing the latest simple news headlines as links. Use $limit to determine how many headlines to show at the most.

NOTE: place this function in functions.content.inc.php (new) instead of functions.inc.php as mentioned in my firt post.

function get_simple_news_headlines($limit) {
  $dbr = Database::$content->query("
  SELECT newsitem.id, newsitem.title, newsitem.time, page.page
  FROM ".Database::$db_settings['news_table']." AS newsitem
  LEFT JOIN ".Database::$db_settings['pages_table']." AS page
  ON newsitem.page_id = page.id
  ORDER BY newsitem.time DESC
  LIMIT " . $limit
  );
  $headlines = '';
  while($row=$dbr->fetch()){
    $headlines .= "<li><a href=\"". $row['page'] .",". $row['id'] ."\">". $row['title'] ."</a> <span class=\"timestamp\">".date("M jS, Y, g:i a",$row['time'])."</span></li>";
  }
  return $headlines;
}

Call the function from any page content like so ...

<ul>[function:get_simple_news_headlines(5)]</ul>
 

Complete thread:

 RSS Feed of thread

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