Contenido API - Article Object Collection

This class is used to manage multiple Contenido article objects in a collection.

The constructor awaits an associative array as parameter with the following schema:

array( string paramname => mixed value );

The parameter idcat is required: array('idcat'=>n)

Legal parameter names are:

idcat - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited start - include start article in the collection, defaults to false artspecs - Array of article specifications, which should be considered order - articles will be orderered by this article property, defaults to 'created' direction - Order direcion, 'asc' or 'desc' for ascending/descending, defaults to 'asc' limit - Limit numbers of articles in collection

You can easy create article lists/teasers with this class.

To create an article list of category 4 (maybe a news category) use:

$myList = new ArticleCollection(array("idcat"=>4);

while ($article = $myList->nextArticle()) { // Fetch the first headline $headline = $article->getContent('htmlhead', 1); $idart = $article->getField('idart');

// Create a link echo ''.$headline.'<br/>'; }

package Contenido API
version 1.0
author Jan Lengowski <Jan.Lengowski@4fb.de>
copyright four for business AG

 Methods

Article Collection Constructor

ArticleCollection(array $options) : void

Parameters

$options

array

Options array with schema array("option"=>"value"); idcat (required) - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited artspecs - Array of article specifications, which should be considered start - include start article in the collection, defaults to false order - articles will be orderered by this property, defaults to 'created' direction - Order direcion, 'asc' or 'desc' for ascending/descending limit - Limit numbers of articles in collection

Extracts all articles from a specified category id and stores them in the internal article array

_getArticlesByCatId(int $idcat) : void
access private

Parameters

$idcat

int

Category Id

Set the Object properties

_setObjectProperties(array $options) : void
access private

Parameters

$options

array

Options array with schema array("option"=>"value"); idcat (required) - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited artspecs - Array of article specifications, which should be considered start - include start article in the collection, defaults to false order - articles will be ordered by this property, defaults to 'created' direction - Order direcion, 'ASC' or 'DESC' for ascending/descending limit - Limit numbers of articles in collection

Iterate to the next article, return object of type Contenido Article Object if an article is found.

nextArticle() : object

False otherwise.

Returns

objectContenido Article Object

Select a page if the results was divided before.

setPage(int $iPage) : void

$collection->setResultsPerPage(2); $collection->setPage(1);

// Iterate through all articles of page two while ($art = $collection->nextArticle()) { ... }

access public

Parameters

$iPage

int

The page of the article collection

Split the article results into pages of a given size.

setResultPerPage(int $resPerPage) : void

Example: Article Collection with 5 articles

[0] => 250 [1] => 251 [2] => 253 [3] => 254 [4] => 255

$collection->setResultPerPage(2)

Would split the results into 3 pages

[0] => [0] => 250 [1] => 251 [1] => [0] => 253 [1] => 254 [2] => [0] => 255

A page can be selected with

$collection->setPage(int page)

access public

Parameters

$resPerPage

int

Return ONLY the Start-Article

startArticle() : object
access public

Returns

objectContenido Article Object

 Properties

 

$aPages : array
 

$articles : array
 

$artspecs : array
 

$client : int
 

$cnt : int
 

$count : int
 

$db : object
 

$direction : string
 

$iCountPages : int
 

$iResultPerPage : int
 

$lang : int
 

$limit : int
 

$order : string
 

$start : int
 

$startId : int
 

$tab : array