This class contains functions for the article helper in CONTENIDO.
The article collector returns you a list of articles, which destination you can choose.
You have the ability to limit, sort and filter the article list. You can configure the article collector with an options array, which can include the following configuration. - idcat - category ID - categories - array with multiple category IDs - lang - language ID, active language if ommited - client - client ID, active client if ommited - artspecs - array of article specifications, which should be considered - offline - include offline article in the collection, defaults to false - offlineonly - only list offline articles, defaults to false - start - include start article in the collection, defaults to false - startonly - only list start articles, defaults to false - order - articles will be ordered by this property, defaults to created - direction - order direcion, ASC'or DESC for ascending/descending, defaults to DESC - limit - limit numbers of articles in collection, default to 0 (unlimited)
deprecated | [2012-10-22] This class is deprecated. Use cArticleCollector instead.
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.' '; } |
---|---|
package | Core |
ArticleCollection($options)
deprecated | [2011-03-15] Old constructor function for downwards compatibility |
---|
__construct(array $options) : void
If options are defined, the loading process is automatically initiated.
deprecated | [2012-10-22] This class is deprecated. Use cArticleCollector instead. |
---|
array
array with options for the collector (optional, default: empty array)
count() : int
Returns the amount of all loaded articles.
inherited_from | \cArticleCollector::count() |
---|
int
current() : mixed
inherited_from | \cArticleCollector::current() |
---|
mixed
key() : int | mixed
inherited_from | \cArticleCollector::key() |
---|
int
mixed
loadArticles() : void
next() : void
inherited_from | \cArticleCollector::next() |
---|
nextArticle() : bool | \cApiArticleLanguage
Returns the next article.
inherited_from | \cArticleCollector::nextArticle() |
---|
rewind() : void
inherited_from | \cArticleCollector::rewind() |
---|
seek(int $position)
inherited_from | \cArticleCollector::seek() |
---|
int
position to load
\cOutOfBoundsException |
---|
setOptions(array $options) : void
Validates incoming options and sets the default of the missing options.
inherited_from | \cArticleCollector::setOptions() |
---|
array
array with option
setPage(int $page) : void
Select a page if the results was divided before.
$collection->setResultPerPage(2); $collection->setPage(1);
// Iterate through all articles of page two while ($art = $collection->nextArticle()) { ... }
inherited_from | \cArticleCollector::setPage() |
---|
int
The page of the article collection
setResultPerPage(int $resPerPage) : void
Split the article results into pages of a given size.
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)
inherited_from | \cArticleCollector::setResultPerPage() |
---|
int
startArticle() : \cApiArticleLanguage
Returns the start article of a category. Does work only if one category was requested.
inherited_from | \cArticleCollector::startArticle() |
---|
\cBadMethodCallException |
---|
valid() : bool
inherited_from | \cArticleCollector::valid() |
---|
bool
$_articles : array
inherited_from | \cArticleCollector::$$_articles |
---|
$_currentPosition : int
inherited_from | \cArticleCollector::$$_currentPosition |
---|
$_pages : array
inherited_from | \cArticleCollector::$$_pages |
---|
$_startArticles : array
inherited_from | \cArticleCollector::$$_startArticles |
---|