Ich habe den Code von Andreas noch um die Abfrage der Metadaten on-/offline ergänzt. Für alle hier noch einmal die Ein- und Ausgabe.
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;
?>
Wer z.B. einen Newsslider o.ä. braucht, lässt die Erstellung der Pagination weg und strickt sich die benötigten Elemente drumrum (Jquery, Javascript und ein wenig html).
News lassen sich mit diesem Modul z.B. erstellen.
Eingabe:
Code: Alles auswählen
<?php
$timestamp = time();
$datum = date("d.m.Y - H:i", $timestamp);
?>
<strong>Datum:</strong>
<br>
<input type="text" name="VALUE[3]" value="<?php echo $datum; ?>" size="30" class="inp100" />
<br>
<br>
<strong>Überschrift:</strong><br>
<input type="text" name="VALUE[2]" value="REX_VALUE[2]" size="80" class="inp100" />
<br><br>
<strong>Fliesstext</strong>:<br />
<textarea name="VALUE[1]" cols="80" rows="10" class="inp100">REX_HTML_VALUE[1]</textarea>
<br /><br />
<br />
<hr>
<strong>Artikelfoto (Wenn es in diesen News keine Bilder gibt, einfach leerlassen):</strong><br />
REX_MEDIA_BUTTON[1]
<?
if ("REX_FILE[1]" != "") {
echo "<br/><strong>Vorschau</strong>:<br/>";
echo "<img src=".$REX[HTDOCS_PATH]."/files/REX_FILE[1] width='250'><br />";
}
?>
<br/>
<strong>Title des Fotos (Alternativtext)</strong>:<br />
<input type="text" name="VALUE[6]" value="REX_VALUE[6]" size="80" class="inp100" />
<br /><br />
<strong>Ausrichtung des Artikelfotos</strong>:<br />
<strong>Hochformatige Bilder bitte rechts ausrichten</strong><br />
<select name="VALUE[4]" class="inp100">
<option value='l' <?php if ("REX_VALUE[4]" == 'l') echo 'selected'; ?>>links vom Text</option>
<option value='r' <?php if ("REX_VALUE[4]" == 'r') echo 'selected'; ?>>rechts vom Text</option>
<option value='m' <?php if ("REX_VALUE[4]" == 'm') echo 'selected'; ?>>Standard</option>
</select><br />
<br />
<strong>Größe des Artikelfotos</strong>:<br />
<input type="text" name="VALUE[5]" value="REX_VALUE[5]" size="30" class="inp100" />
<br />(w=Breite, h=Höhe, a=die längere Seite, z.B.: 128w)
<br />
<hr>
<br />
<strong>Bitte Bilder für Galerie auswählen (Wenn es in diesen News keine Bilder gibt, einfach leerlassen):</strong>
<br />
<strong>Bild(er) auswählen ...</strong>
<br/>
REX_MEDIALIST_BUTTON[1]
<div id="REX_MEDIALIST_PREVIEWC" style="display:none;margin-bottom:25px;">Vorschau:<br /><img id="REX_MEDIALIST_PREVIEW" src="../files/clear.gif" style="cursor:pointer;border:solid 1px #999;" alt="Vorschau" title="Vorschau" /></div>
<div style="display:block;width:370px;"></div>
<br/>
<br/>
<strong>maximale Bildgröße Galeriebild</strong></td>
<br/>
<input type="text" style="width:70px;" name="VALUE[8]" value="REX_VALUE[8]" />
<br />(w=Breite, h=Höhe, a=die längere Seite, z.B.: 128w)
<br/>
<br/>
<strong>CSS-Klasse für die Links</strong></td>
<br/>
<input type="text" style="width:98%;" name="VALUE[7]" value="REX_VALUE[7]" />
<script type="text/javascript">
function addEvent( obj, type, fn )
{
if (obj.addEventListener) {
obj.addEventListener( type, fn, false );
} else if (obj.attachEvent) {
obj["e"+type+fn] = fn;
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
obj.attachEvent( "on"+type, obj[type+fn] );
}
}
function rex_media_preview(){
var strFileName = document.getElementById("REX_MEDIALIST_SELECT_1").value;
if ( (strFileName.lastIndexOf(".jpg")>0) || (strFileName.lastIndexOf(".jpeg")>0) || (strFileName.lastIndexOf(".gif")>0) || (strFileName.lastIndexOf(".png")>0) || (strFileName.lastIndexOf(".bmp")>0) ) {
newImage = new Image();
newImage.onload = function() {
document.getElementById("REX_MEDIALIST_PREVIEW").src = newImage.src;
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "block";
}
newImage.src = "../index.php?rex_resize=196a__"+document.getElementById("REX_MEDIALIST_SELECT_1").value;
} else {
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "none";
}
}
function rex_media_hidepreview(){
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "none";
}
function rex_toggle_plusoptions(){
if ( document.getElementById("moduleplusoptions").style.display == "none" ) {
document.getElementById("moduleplusoptions").style.display = "block";
} else {
document.getElementById("moduleplusoptions").style.display = "none";
}
}
addEvent(document.getElementById("REX_MEDIALIST_SELECT_1"), "change", rex_media_preview);
addEvent(document.getElementById("REX_MEDIALIST_SELECT_1"), "click", rex_media_preview);
addEvent(document.getElementById("REX_MEDIALIST_PREVIEW"), "click", rex_media_hidepreview);
</script>
<br /><br />
<?php rex_a79_help_overview(); ?>
Ausgabe:
Code: Alles auswählen
<?
// Datum
$date= "";
if ("REX_VALUE[3]" != "") $date='<h5 class="date">REX_VALUE[3]</h5>';
// Ueberschrift
$headline= "";
if ("REX_VALUE[2]" != "") $headline='<h1>REX_VALUE[2]</h1>';
// Ausrichtung des Bildes
if ("REX_VALUE[4]" == "l") $float = "flt_lft";
if ("REX_VALUE[4]" == "r") $float = "flt_rgt";
if ("REX_VALUE[4]" == "m") $float = "flt_no";
// Wenn Bild eingefuegt wurde, Code schreiben
$file = "";
if ("REX_FILE[1]" != "") $file = '<div class="'.$float.'"><a href="' . $REX['HTDOCS_PATH'] . 'files/REX_FILE[1]" rel="shadowbox"><img src="'. $REX['HTDOCS_PATH'] . 'index.php?rex_resize=REX_VALUE[5]__REX_FILE[1]" title="'."REX_VALUE[6]".'" alt="'."REX_VALUE[6]".'" /></a></div>';
// Fliesstext
$input =<<< EOT
REX_HTML_VALUE[1]
EOT;
$textile = new Textile;
$text = "";
if ("REX_VALUE[1]" != "") $text = $textile->TextileThis($input);
$text = str_replace("###"," ",$text);
print $date.$headline.$file.$text;
?>
<?php
//GALERIE
/**
* --------------------------------------------------------------------
*
* Modul-Output: Beispielmodul fuer Addon Shadowbox
*
* Autor: Andreas Eberhard, andreas.eberhard@gmail.com
* http://rex.andreaseberhard.de
*
* --------------------------------------------------------------------
*/
unset($rxmodule);
// REDAXO-Version
$rxmodule['rexversion'] = isset($REX['VERSION']) ? $REX['VERSION'] . $REX['SUBVERSION'] : $REX['version'] . $REX['subversion'];
// Bilddateien aus Medialist
$rxmodule['imagelist'] = explode(',', trim("REX_MEDIALIST[1]"));
// maximale Bildgroesse
$rxmodule['imgsize'] = trim("REX_VALUE[8]");
if ($rxmodule['imgsize']=='')
{
$rxmodule['imgsize'] = '128a';
}
// CSS-Klasse
$rxmodule['cssclass'] = trim("REX_VALUE[7]");
// Zufallszahl fuer Ausgabe
srand((double)microtime()*1000000);
$rxmodule['random'] = rand (100,900) . rand (100,900);
// Links fuer die Bilder ausgeben
foreach ($rxmodule['imagelist'] as $rxmodule['file']) {
$rxmodule['media'] = OOMedia::getMediaByName($rxmodule['file']);
if ($rxmodule['media']) {
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { // REDAXO 3.2.x, REDAXO 3.01, REDAXO 3.11
$rxmodule['mediatitle'] = str_replace(array("\r\n", "\n", "\r"), ' ', $rxmodule['media']->getTitle());
}
if ( in_array($rxmodule['rexversion'], array('40', '41', '42', '43')) ) { // REDAXO 4.0.x, 4.1.x, 4.2.x
$rxmodule['mediatitle'] = str_replace(array("\r\n", "\n", "\r"), ' ', $rxmodule['media']->getValue('description'));
}
if (trim($rxmodule['mediatitle']=='') or !$rxmodule['mediatitle']) {
$rxmodule['mediatitle'] = $rxmodule['file'];
}
echo '<a class="' . $rxmodule['cssclass'] . '" rel="shadowbox[sb' . $rxmodule['random'] . ']" href="' . $REX['HTDOCS_PATH'] . 'files/' . $rxmodule['file'] . '" title="' . $rxmodule['mediatitle'] . '">';
echo '<img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=' . $rxmodule['imgsize'] . '__' . $rxmodule['file'] . '" alt="' . $rxmodule['mediatitle'] . '" />';
echo '</a>' . "\n";
}
}
?>
<?php
$cat = OOCategory::getCategoryById(REX_CATEGORY_ID);
$start_art = $cat->getStartArticle();
echo '<p>« <a href="'.$start_art->getUrl().'" title="Zurück zur Übersicht">Zurück zur Übersicht</a></p>';
?>
Leider weiß ich nicht mehr bei wem ich mich bezügl. des Codes bedient habe. Irgendwie ist bei den ganzen Versuchen die Doku auf der Strecke geblieben. Sorry, aber einen ganz herzlichen Dank allen die Code dazu beigesteuert haben.
Jens