pobject > ppage > pdir > pnewspaper

The newspaper class is a container for articles. It allows you to manage and display articles based on start and end timestamps, as well as scenario's.

Methods

(string) get_articles
(string) clear_articles
 

get_articles

(array) get_articles($display, $max=0, $start=0, $end=0, $nls='', $priority_date=0)

(string) $display The display phase to use. See /system/newspaper/displays/
(int) $max The maximum number of articles to return.
(int) $start The start date to start searching for articles. Unix timestamp.
(int) $end The end date to stop searching for articles. Unix timestamp.
(string) $nls The two-letter ISO language code, e.g. 'en'.
(int) $priority_date The 'current' date used to calculate the priorities for each article. Unix timestamp.

This method searches the newspaper for articles (particle) contained in it which match the start and end timestamps. An article is 'current' if its end timestamp is after $start and its start timestamp is before $end. For each article a priority counter is calculated. This is based on its base priority, saved in the article itself, combined with the difference in minutes between $priority_date and the start timestamp of the article. The closer to $priority_date an article's start is, the higher the priority.

The result is an array of article objects, sorted by priority, highest first.

example 1: a list of at most 5 current articles.

<pinp>
$date = getvar( 'date' );
if ( !$date ) {
$date = time();
}
$articles = get_articles( 'default', 5, $date, $date, $nls, $date);
if ( $articles ) {
echo '<ul>';
foreach ( $articles as $article ) {
$article->call( 'show.html' );
}
echo '</ul>';
}
clear_articles();
</pinp>

clear_articles

(void) clear_articles()

This method clears the internal article cache created by get_articles(). This is not done automatically, you must do this yourself if you have more than one newspaper listing.