Hallo,
das Teaser-Modul, das ich bei auf der oben genannten Seite verwendet habe ist das hier (ist glaube ich sogar das Vorinstallierte von Redaxo):
Eingabe:
Code: Alles auswählen
<?php
//---MODULE MODIFIED BY------------------
//-- a-concept internet.studio
//-- Sven Albert-Pedersen
//-- www.a-concept.de / www.svenalbert.de
//-----------------------------------------------
//-- version 1.0
//-- date 23-mar-2006
//-----------------------------------------------
?>
<strong>Anzahl der Artikel pro Seite</strong><br />
<input name="VALUE[1]" value="REX_VALUE[1]" class="inp100" /><br />
<br />
<strong>Anzahl der Wörter pro Artikel</strong><br />
<input name="VALUE[2]" value="REX_VALUE[2]" class="inp100" /><br />
Ausgabe:
Code: Alles auswählen
<?php
//---MODULE MODIFIED BY------------------
//-- a-concept
//-- Sven Albert-Pedersen
//-- www.a-concept.de / www.svenalbert.de
//-----------------------------------------------
$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";
// Nur im Frontend
//if (!$REX['REDAXO']):
// Sortierfunktion
if (!function_exists(sortArticlesByPrio)) {
function sortArticlesByPrio( $artA, $artB) {
$createA = $artA->_prior;
$createB = $artB->_prior;
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
$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);
$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 = ' [...] <p><a href="'.rex_getUrl($articleId).'">... weiterlesen »</a></p> ';
$newString = $link.'</p>';
if ($isCloseParagraph == '</p>') {
$output = substr_replace($output,$newString,-4);
}
else {
$output .= $newString;
}
// opened & closed DIVs zählen und ggf. closing Tags ergänzen
// ----------------------------------------------------------
// MODIFIED by Sven Albert-Pedersen * alfa-x (at) web (dot) de
$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 '<p><div class="news">'.$output.'</div></p>';
}
}
$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;
?>
Gruss,
Daniel