Hallo Zusammen,
muss mich jetzt auchmal zu Wort melden.
Als erstes möchte ich sagen Redaxo ist absolut genial!!!
Habe einige CMS Systeme ausprobiert und bin jetzt nach fast 1. Jahr hier hängen geblieben. Man merkt sehr schnell warum Redaxo soviele Vorteile hat. Ich liebe die freie Gestaltungsmöglichkeit. Denn ich kann für jeden Redakteur eine eigene Eingabemaske bauen ohne das Layout anzugreifen.
Habe versucht das Forum auch für die Fehlersuche weitestgehend zu nutzen, aber nun habe ich das Problem:
Der Teaser funktioniert einwandfrei, nur möchte ich halt auch keine Bilder in der Teaseransicht, da diese das Layout zerstören.
Ich habe folgendes gefunden:
Code: Alles auswählen
$articleContent = preg_replace("/<img.+\/>?>/","",$articleContent);
Habe das in das Modul kopiert, aber die Bilder werden trotzdem angezeigt.
Was habe ich falsch gemacht?
Wahrscheinlich die Reihenfolge oder?
Mein modul:
Code: Alles auswählen
<?php
$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";
// Nur im Frontend
//if (!$REX['REDAXO']):
// Sortierfunktion
if (!function_exists(sortArticlesByUpdateDate)) {
function sortArticlesByUpdateDate( $artA, $artB) {
$createA = $artA->_updatedate;
$createB = $artB->_updatedate;
if ( $createA == $createB) {
return 0;
}
return $createA > $createB ? -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 nach Erstellungsdatum
if ( $articles_length > 0) {
usort( $articles, "sortArticlesByUpdateDate");
}
$article_list = array_slice( $articles, $start, $offset);
foreach ( $article_list as $ooarticle) {
if ($ooarticle->isOnline(true)) {
$articleId = $ooarticle->getId();
$article = new article();
$article->setArticleId( $articleId);
$articleContent = $article->getArticle();
// Leerzeichen entfernen am Anfang und Ende des Strings
$articleContent = trim($articleContent);
// Leerzeichen vor </p> einfuegen.
// Sonst wird das letzte Wort eines Absatzes und das erste Wort
// des nachfolgenden Absatzes als ein Wort erkannt
$articleContent = str_replace("</p>", " </p>", $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);
$articleContent = preg_replace("/<img.+\/>?>/","",$articleContent);
$output = "";
$words = explode(" ",$articleContent);
$wordsCount = count($words);
if ($wordsCount < $wordsPerArticle) $wEnd = $wordsCount;
else $wEnd = $wordsPerArticle;
for ($w=0;$w<$wEnd;$w++) {
$output .= $words[$w]." ";
}
// Leerzeichen entfernen am Anfang und Ende des Strings
$output = trim($output);
$isCloseParagraph = substr($output,-4);
$link = '<br> <a href="'.rex_getUrl($articleId).'">...mehr</a>';
$newString = $link.'</p>';
if ($isCloseParagraph == '</p>') {
$output = substr_replace($output,$newString,-4);
}
else {
$output .= $newString;
}
print '<div class="teaser">'.$output.'</div>';
}
}
$prevStart = $start - $offset;
if ( $prevStart < 0)
{
$prevStart = '';
}
$nextStart = $start + $offset;
if ( $nextStart >= $articles_length)
{
$nextStart = '';
}
$link_format = '<a href="index.php?article_id=REX_ARTICLE_ID&start=%s">%s</a>';
// Vorherige Seite Link
if ( $prevStart !== '') {
$backLink = sprintf( $link_format, $prevStart, '<< vorherige Seite');
}
// Nächste Seite
if ( $nextStart !== '') {
$nextLink = sprintf( $link_format, $nextStart, 'nächste Seite >>');
}
if ($backLink != "" AND $nextLink != "") {
print '<div class="teaserNav"><p>'.$backLink.' | '.$nextLink.'</p></div>';
}
elseif ($nextLink != "") {
print '<div class="teaserNav"><p>'.$nextLink.'</p></div>';
}
elseif ($backLink != "") {
print '<div class="teaserNav"><p>'.$backLink.'</p></div>';
}
//endif;
?>