Skip to content

Instantly share code, notes, and snippets.

@tbaddade
Created June 6, 2013 09:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tbaddade/5720452 to your computer and use it in GitHub Desktop.
Save tbaddade/5720452 to your computer and use it in GitHub Desktop.
REDAXO :: Alle Artikel einer Kategorie inklusive die Artikel deren Kinder (rekursiv)
<?php
$root_id = REX_CATEGORY_ID;
$ignore_offline = true;
function getArticles ($id, $ignore_offline) {
$return = array();
if ($id > 0) {
$cats = OOCategory::getChildrenById($id, $ignore_offline);
foreach ($cats as $cat) {
$articles = OOArticle::getArticlesOfCategory($cat->getId(), $ignore_offline);
foreach ($articles as $article) {
if ($article->isStartarticle()) {
continue;
}
$return[] = $article;
}
if (count($cat->getChildren($ignore_offline)) > 0) {
$return = array_merge($return, getArticles($cat->getId(), $ignore_offline));
}
}
}
return $return;
}
$articles = getArticles($root_id, $ignore_offline);
echo '<pre style="text-align: left">';
print_r($articles);
echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment