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 '<a href="front_content.php?idcat='.$myList->idcat.'&idart='.$idart.'">'.$headline.'</a><br/>';

}

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

 Methods

ArticleCollection()

ArticleCollection($options) 

deprecated [2011-03-15] Old constructor function for downwards compatibility

Parameters

$options

Article Collection Constructor

__construct(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

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

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

 Properties

 

List of articles, splitted into pages

$aPages : array

 

Articles

$articles : array

 

Article Specifications

$artspecs : array

 

Client ID

$client : int

 

Result Counter

$cnt : int

 

Articles in collection

$count : int

 

Database Object

$db : object

 

Sort direction

$direction : string

 

Pages in Article Collection

$iCountPages : int

 

Results per page

$iResultPerPage : int

 

Language id

$lang : int

 

Limit of numbers of articles in collection

$limit : int

 

Sort order

$order : string

 

Include the Start-Article

$start : int

 

Id of the start article

$startId : int

 

Config array

$tab : array