Hier noch einmal der komplette Code samt Eingabe und Ausgabe inkl. Auswahl CType, on-/offline, Pagination allerdings ohne das Akkordeon-Zeugs.
Eingabe:
Code: Alles auswählen
<?php
// -- http://www.redaxo.de/165-0-moduldetails.html?module_id=66
// -- modified by Andreas Otte --
// -- otte@otte.net --
// -- Version 1.0 --
// ---------------------------------------------
//---MODULE MODIFIED BY------------------
//-- a-concept internet.studio
//-- Sven Albert-Pedersen
//-- http://a-concept.de / http://svenalbert.de
//-----------------------------------------------
//-- version 1.3
//-- date 09-jan-2009
//-----------------------------------------------
function PrintCategorieOptions($cat = null) {
$selectCats = null;
if ( is_int( $cat)) {
$selectCats = array( OOCategory::getCategoryById( $cat));
} else {
$selectCats = OOCategory::getRootCategories();
}
foreach ( $selectCats as $selectCat) {
add_cat_option( $selectCat);
}
}
function add_cat_option( &$cat, $groupName = '') {
if( empty( $cat)) {
return;
}
print_link($cat->getName(), $cat->getId(), $groupName);
if ( $cat->getChildren()) {
$childs = $cat->getChildren();
foreach ( $childs as $child) {
if ($child->getChildren()) {
add_cat_option( $child, $groupName." ");
} else {
add_cat_option( $child, $groupName." ");
}
}
}
}
function print_link($catName, $catId, $groupName) {
global $selectedCat;
if ( "REX_VALUE[4]" == $catId) {
// selected
echo "<option value=\"" . $catId . "\" selected>" . $groupName.$catName . "</option>\n";
} else {
echo "<option value=\"" . $catId . "\">" . $groupName.$catName . "</option>\n";
}
}
?>
<strong>Kategorie:</strong>
<br />
<select name="VALUE[4]">
<?php PrintCategorieOptions(); ?>
</select>
<br />
<br />
<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 />
<br />
<strong>Sortierung nach</strong><br />
<select name="VALUE[3]" ><?
foreach (array("prio","updatedate","createdate","name") as $value) {
echo '<option value="'.$value.'" ';
if ( "REX_VALUE[3]"=="$value" ) {
echo 'selected="selected" ';
}
echo '>'.$value.'</option>';
}
?></select>
<br />
<br />
<strong>Welche Artikelspalte soll ausgelesen werden?</strong>
<br />
<select name="VALUE[6]" >
<?php
foreach (array("1","2","3","4","5","6") as $value) {
echo '<option value="'.$value.'" ';
if ( "REX_VALUE[6]"=="$value" ) {
echo 'selected="selected" ';
}
echo '>'.$value.'</option>';
}
?>
</select>
Ausgabe:
Code: Alles auswählen
<?php
//---MODULE MODIFIED BY--------------------------
//-- a-concept internet.studio
//-- Sven Albert-Pedersen
//-- http://a-concept.de / http://svenalbert.de
//-----------------------------------------------
//-- version 1.3
//-- date 09-jan-2009
//-----------------------------------------------
//-- Nachträglich eingefügt:
//--
//-- * Zählen und Schließen von DIVs & SPANs
//-- * Auswahl der Sortierung nach Prio
//-- * Ausblendung eines Bildes im Artikel
//-- * Funktionalität mit mehrsprachigen Webseiten
//-- * Zurück-Link, wenn Seite über den Teaser aufgerufen wurde
//-- * v1.24 Texte für $nextLink und $backLink im oberen Bereich der Datei
//-- * v1.3 Schließen der Tags in einen Array und eine For-Schleife verpackt
//--
//-- Bugfixes:
//-- v1.23 Moduleingabe: Select hatte falschen Variablennamen
//-----------------------------------------------
//---BEZEICHNUNG DER BLÄTTER- und WEITER-LINKS---
//--
//--
$backLink_text = 'vorige Seite';
$nextLink_text = 'nächste Seite';
$moreLink_text = 'weiterlesen';
//--
//--
//-----------------------------------------------
$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";
$sorting_order = "REX_VALUE[3]";
$catId = "REX_VALUE[4]";
//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( 58); // alle Kategorien die Du "indizieren" willst
// $cats = $catId;
$cats = "REX_VALUE[4]";
$articles = array();
// foreach ( $cats as $catId) {
// $cat = OOCategory::getCategoryById( $catId);
$cat = OOCategory::getCategoryById($catId);
$childs = $cat->getArticles( true);
if ( is_array( $childs)) {
if('REX_VALUE[5]') {
usort($childs, 'sortArticlesBy'.$sorting_order);
}
// 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() == 15) {
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);
// Article-Ctype angeben
$slice = "REX_VALUE[6]";
$articleContent = $article->getArticle($slice);
// Berücksichtigung Metadaten on-/offline
$time = time();
if($article->getValue("online_from") != "" &&
$article->getValue("online_from") > $time ||
$article->getValue("online_to") != "" &&
$article->getValue("online_to") < $time-86400)
{
continue;
}
// DIV-Container mit Bildern entfernen
# $articleContent = preg_replace('/<div style=\".*?<\/div>/', "",$articleContent);
# $articleContent = preg_replace('/<div class=\"float(Right|Left)\" .*?<\/div>/', "",$articleContent);
// Modifizierte Ausgabe für die Teaserausgabe - Hauck-Startseite, edit by Otte
$articleContent = preg_replace("/<div class=\"float(Right|Left)\".*?<\/div>/", "",$articleContent);
// 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);
# echo 'count: <b>'.$wordsCount.'</b>';
# echo 'teaser: <b>'.$wordsPerArticle.'</b>';
if ($wordsCount < $wordsPerArticle) {
$wEnd = $wordsCount;
# echo 'KLEINER';
$link = '';
}
else {
$wEnd = $wordsPerArticle;
# echo 'GROESSER GLEICH';
$link = ' … <a href="'.rex_getUrl($articleId, $REX['CUR_CLANG'], array('goback' => "15")).'" 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.'</p>';
if ($isCloseParagraph == '</p>') {
$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
$openingTags = array("<a " , "<i>" , "<strong>" , "<b>" , "<li" , "<ul" , "<span" , "<div");
$closingTags = array("</a>" , "</i>" , "</strong>" , "</b>" , "</li>" , "</ul>" , "</span>" , "</div>");
$substitTags = array("</a>" , "</i>" , "</strong>" , "</b>" , "</li></ul>" , "</ul>" , "</span>" , "</div>");
for($i=0; $i < count($openingTags); $i++)
{
$opening = ''; $closing = ''; $missing = '';
$opening = substr_count($output, $openingTags[$i]);
$closing = substr_count($output, $closingTags[$i]);
$missing = $opening - $closing;
if ($opening > $closing)
{
while ($missing > 0)
{
$output .= $substitTags[$i];
$missing = $missing - 1;
}
}
}
// ----------------------------------------------------------
// END MODIFICATION
print '<div class="news">'.$output.'<hr /></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;
?>
hth
Jens