mgd_list_topic_articles

(Midgard 1.4.2 'Bifrost')

mgd_list_topic_articles -- List articles under topic

Description

object mgd_list_topic_articles (int topic, string [sort], int [type], int [up])

Minimum version: Midgard 1.1.1

Lists all articles that have their topic field set to topic. The optional parameter sort is used to sort the articles, and can be one of: "alpha", "reverse alpha", "name", "reverse name", "score", "reverse score", "calendar", "reverse calendar", "revised", "reverse revised". Default sort is by created date. The optional parameter type can be used to filter articles. Default value is no filter. The optional parameter up can be used to select articles by their up field (this is available in Midgard 1.4.1 (Bifrost)).

Returns an object traversable by calling fetch() if successful. Returns FALSE on failure.


<?php
$topic = 123;
$article = mgd_list_topic_articles( $topic, "score" );
if ( $article->N == 0 ) {
  echo "No article";
} else {
  while ( $article->fetch() ) {
    echo $article->name . "<br>\n";
  }
  echo "$article->N article", ( $article->N == 1 ) ? '' : 's';
}
?>