cArticleCollector

The class cArticleCollector provides an easy way to get an iterable array of articles that all share certain characteristics.

Its constructor expects an array of options to filter out articles:

KeyTypeDefault valueDescription
idcatintnoneID of the category that all results should belong to
categoriesarraynone

Array of category ID's.

If this and idcat are omitted the class will load all articles regardless of category

langintcurrent language IDLanguage of the articles as ID
clientintcurrent client IDClient of the articles as ID
artspecsarraynoneArray of Article Specification IDs. The article must have one of those to match.
offlinebooleanfalseInclude offline articles
offlineonlybooleanfalseOnly return offline articles
startbooleanfalseInclude start articles
startonlybooleanfalseOnly return start articles
orderstring"created"Column that the result should be sorted after
directionstring"DESC""ASC" or "DESC" depending on if you want the sorting to be ascending or descending.
limitint0

A limit on how many articles are going to be loaded

0 means that there is no limit

Examples

// Get all articles of this client and language that are offline and print their titles
$collector = new cArticleCollector(array(
	"offlineonly" => true
));
 
foreach($collector as $article) {
	echo($article->get("title") . "<br>");
}

 

You can find out more about this class in the API documentation.