versuchs mal so:holger hat geschrieben: Hast du da ne schnelle Lösung ?
Code: Alles auswählen
<?php
if (!function_exists('truncate'))
{
function truncate($string, $length = 80, $etc = '...', $break_words = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length)
{
$length -= strlen($etc);
if (!$break_words)
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length +1));
return substr($string, 0, $length).$etc;
}
else
return $string;
}
}
if( !function_exists( 'sortArtPrio')) {
function sortArtPrio( $articleA, $articleB) {
$prioA = $articleA->getPriority();
$prioB = $articleB->getPriority();
if ( $prioA == $prioB) {
return 0;
}
return $prioA < $prioB ? -1 : 1;
}
}
$cat = OOCategory::getCategoryById(REX_CATEGORY_ID);
$childs = $cat->getArticles( true);
usort( $childs, "sortArtPrio"); // sortieren
if ( is_array( $childs)) {
foreach ( $childs as $child) {
$id = $child->getId();
if ( $id == REX_ARTICLE_ID) continue;
if ( !$child->isOnline()) continue;
$article = new article( $id);
$content = truncate( strip_tags( $article->getArticleContent()), 150); // Ersten 100 Zeichen
$media = $child->getFileMedia();
print( '<div class="news-article">');
if ( $media != null) {
printf( '<div class="image">%s</div>', $media->toHTML());
}
printf( '<div class="text">%s</div>', $content);
print( '</div');
break;
}
}
?>
Markus