redaxo/redaxo — Issue #26: getChildren in Frontend not work
Author: joachimdoerr
Created: 2011-12-18 08:32:44+00:00
State: open

Ich hab das Kategorien Listen Modul aus der Demo eingesetzt und OOCategory durch rex_ooCategory entsprechend ersetzt. Im Backend wird auch alles korrekt dargestellt nur im Forstend gibt es folgenden Fehler:

[18-Dec-2011 09:29:02] PHP Fatal error: Call to a member function getChildren() on a non-object in rex://module/7/output on line 4

Hier der Modul Output Code:
getValue('category_id'));
$cats = $cat->getChildren();

$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";

if (is_array($cats))
{
$i = 0;
foreach ($cats as $cat)
{
$i += 1;
if ($i <= $itemsPerSide)
{
if ($cat->isOnline())
{

$catId = $cat->getId();
$catName = $cat->getName();
$article = $cat->getArticles();

if (is_array($article))
{
foreach ($article as $var)
{
$articleId = $var->getId();
$articleName = $var->getName();
$art = new rex_article($articleId);
$articleContent = $art->getArticle();

$articleContent = trim($articleContent);
$articleContent = str_replace('

', '

', $articleContent);
$articleContent = str_replace('
', '
', $articleContent);

$articlePPath = $REX['MEDIAFOLDER'] . 'files/' . $var->getValue('file');

$output = '';
$words = explode(' ', $articleContent);
$wordsCount = count($words);

if ($wordsCount < $wordsPerArticle)
$wEnd = $wordsCount;
else
$wEnd = $wordsPerArticle;

for ($w = 0; $w < $wEnd; $w++)
{
$output .= $words[$w] . ' ';
}

$output = trim($output);

$isCloseParagraph = substr($output, -4);
$isCloseDiv = substr($output, -10);
$link = ' ...mehr';
$newString = $link . '

';

if ($isCloseParagraph == '

')
{
$output = substr_replace($output, $newString, -4);
}
elseif ($isCloseDiv == '

')
{
$output = substr_replace($output, $newString.'

', -10);
}
else
{
$output .= $newString;
}

// print '

'.$articleName.'

';
print '

' . $output . '

';

}
}
}
}
}
}
?>