ich brauche ein Teasermodul, welches den Text in gekürzter Version anzeigt und ein (!) bild aus dem Artikel.
Habe begonnen das Modul Teaser umzubauen.
Jetzt habe ich folgendes Problem:
Im Artikel, der angeteasert werden soll sind ca. 3 Bilder enthalten. Ich möchte aber, dass im Teaser nur das erste Bild angezeigt wird.
Im Moment habe ich dem ersten Bild eine besondere Klasse gegeben und die anderen Bilder mittles css unsichtbar gemacht, aber sie stehen ja leider nun noch im Quelltext. Wie bekomme ich die komplett raus?
aktueller Code des Moduls:
- Code: Alles auswählen
<?php
$backLink_text = 'vorige Seite';
$nextLink_text = 'nächste Seite';
$moreLink_text = 'mehr';
//--
//--
//-----------------------------------------------
$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";
$sorting_order = "REX_VALUE[3]";
//echo $sorting_order;
// Nur im Frontend
//if (!$REX['REDAXO']):
// Sortierfunktionen
// Sortierfunktion by Name
// siehe http://wiki3.redaxo.de?n=R3.Sortiermöglichkeiten
if(!function_exists('sortArticlesByName')) { function sortArticlesByName( $artA, $artB) { $nameA = $artA->getName(); $nameB = $artB->getName(); if ( $nameA == $nameB) { return 0; } $names = array($nameA,$nameB); sort( $names, SORT_STRING); return $names[0] == $nameA ? -1 : 1; } }
// Sortierfunktion by Prio
// siehe http://wiki3.redaxo.de?n=R3.Sortiermöglichkeiten
if (!function_exists('sortArticlesByPrio')) { function sortArticlesByPrio( $artA, $artB) { $prioA = $artA->getPriority(); $prioB = $artB->getPriority(); if ( $prioA == $prioB) { return 0; } return $prioA > $prioB ? 1 : -1; } }
// Sortierfunktion by CreateDate
// siehe http://wiki3.redaxo.de?n=R3.Sortiermöglichkeiten
if(!function_exists('sortArticlesByCreateDate')) { function sortArticlesByCreateDate( $artA, $artB) { $createA = $artA->getCreateDate(); $createB = $artB->getCreateDate(); if ( $createA == $createB) { return 0; } return $createA > $createB ? -1 : 1; } }
// Sortierfunktion by UpdateDate
// siehe http://wiki3.redaxo.de?n=R3.Sortiermöglichkeiten
if(!function_exists('sortArticlesByUpdateDate')) { function sortArticlesByUpdateDate( $artA, $artB) { $updateA = $artA->getUpdateDate(); $updateB = $artB->getUpdateDate(); if ( $updateA == $updateB) { return 0; } return $updateA > $updateB ? -1 : 1; } }
$start = !empty($_GET['start']) ? (int) $_GET['start'] : 0; // Startitem
$offset = $itemsPerSide; // 10 Items pro Seite
$cats = array( REX_CATEGORY_ID); // alle Kategorien die Du "indizieren" willst
$articles = array();
foreach ( $cats as $catId) {
$cat = OOCategory::getCategoryById( $catId);
// CatIds die nicht funktionieren aussortieren
if( $cat === null) {
continue;
}
$cat_articles = $cat->getArticles( true);
foreach ( $cat_articles as $ooarticle) {
// keine Startartikel anzeigen
if ( $ooarticle->isStartPage()) {
continue;
}
// Damit keine Endlosschleife passiert, den Artikel der die Pagination setzt überspringen
if ( $ooarticle->getId() == REX_ARTICLE_ID) {
continue;
}
$articles[] = $ooarticle;
}
}
$articles_length = count( $articles);
// Sortieren
if ( $articles_length > 0) {
if ($sorting_order == "updatedate") {
usort( $articles, "sortArticlesByUpdateDate");
}
elseif ($sorting_order == "prio") {
usort( $articles, "sortArticlesByPrio");
}
elseif ($sorting_order == "name") {
usort( $articles, "sortArticlesByName");
}
elseif ($sorting_order == "createdate") {
usort( $articles, "sortArticlesByCreateDate");
}
}
$article_list = array_slice( $articles, $start, $offset);
foreach ( $article_list as $ooarticle) {
if ($ooarticle->isOnline(true)) {
$articleId = $ooarticle->getId();
$article = new article();
$article->setClang($REX['CUR_CLANG']); // lt. Kommentar, openmind, 01-feb-2007
$article->setArticleId( $articleId);
$articleContent = $article->getArticle(1);
// DIV-Container mit Bildern entfernen
# $articleContent = preg_replace('/<div style=\".*?<\/div>/', "",$articleContent);
$articleContent = preg_replace('/<div class=\"img_(right|left)\">.*?<\/div>/', "",$articleContent);
// Leerzeichen entfernen am Anfang und Ende des Strings
$articleContent = trim($articleContent);
// Leerzeichen vor <br /> einfuegen.
// Sonst wird das letzte Wort einer Zeile und das erste Wort
// des nachfolgenden Zeile als ein Wort erkannt
$articleContent = str_replace("<br />", " <br />", $articleContent);
$output = "";
$words = explode(" ",$articleContent);
$wordsCount = count($words);
if ($wordsCount < $wordsPerArticle) {
$wEnd = $wordsCount;
$link = '';
}
else {
$wEnd = $wordsPerArticle;
$link = ' ... <a href="'.rex_getUrl($articleId, $REX['CUR_CLANG'], array('goback' => "REX_ARTICLE_ID")).'" title="'. $moreLink_text .'">'. $moreLink_text .' »</a>';
}
for ($w=0;$w<$wEnd;$w++) {
$output .= $words[$w]." ";
}
// Leerzeichen entfernen am Anfang und Ende des Strings
$output = trim($output);
$isCloseParagraph = substr($output,-4);
$newString = $link.'';
if ($isCloseParagraph == '') {
$output = substr_replace($output,$newString,-4);
}
else {
$output .= $newString;
}
// opened & closed DIVs/SPANs zählen und ggf. closing Tags ergänzen
// ----------------------------------------------------------
// MODIFIED by Sven Albert-Pedersen * alfa-x (at) web (dot) de
$openedSPANs = substr_count($output, '<span');
$closedSPANs = substr_count($output, '</span>');
$countmissingSPANs = $openedSPANs - $closedSPANs;
if ($openedSPANs > $closedSPANs) {
while ($countmissingSPANs > 0):
$output .= "</span>";
$countmissingSPANs = $countmissingSPANs - 1;
endwhile;
}
$openedDIVs = substr_count($output, '<div');
$closedDIVs = substr_count($output, '</div>');
$countmissingDIVs = $openedDIVs - $closedDIVs;
if ($openedDIVs > $closedDIVs) {
while ($countmissingDIVs > 0):
$output .= "</div>";
$countmissingDIVs = $countmissingDIVs - 1;
endwhile;
}
// ----------------------------------------------------------
// END MODIFICATION
print '<div class="teaser">'.$output.'</div>';
}
}
?>

