Created
June 6, 2013 09:46
-
-
Save tbaddade/5720452 to your computer and use it in GitHub Desktop.
REDAXO :: Alle Artikel einer Kategorie inklusive die Artikel deren Kinder (rekursiv)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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