ArticleCollection()
__construct()
nextArticle()
setPage()
setResultPerPage()
startArticle()
_getArticlesByCatId()
_setObjectProperties()
$aPages
$articles
$artspecs
$client
$cnt
$count
$db
$direction
$iCountPages
$iResultPerPage
$lang
$limit
$order
$start
$startId
$tab
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> |
ArticleCollection($options)
deprecated | [2011-03-15] Old constructor function for downwards compatibility |
---|
__construct(array $options) : void
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
nextArticle() : object
object
Contenido Article ObjectsetPage(int $iPage) : void
$collection->setResultsPerPage(2); $collection->setPage(1);
// Iterate through all articles of page two while ($art = $collection->nextArticle()) { ... }
access | public |
---|
int
The page of the article collection
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 |
---|
int
startArticle() : object
access | public |
---|
object
Contenido Article Object_getArticlesByCatId(int $idcat) : void
access | private |
---|
int
Category Id
_setObjectProperties(array $options) : void
access | private |
---|
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
$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