[phpBB Debug] PHP Warning: in file [ROOT]/ext/tas2580/seourls/event/listener.php on line 213: Undefined array key "FORUM_NAME"
Teaser Problem - REDAXO Forum
Hallo,

Wir haben in letzter Zeit festgestellt, dass die Kommunikation via Slack viel schneller und zielführender ist als ein Beitrag im Forum. Aufgrund der neuen und besseren Möglichkeiten der Kommunikation haben wir uns entschlossen das Forum nur noch als Archiv zur Verfügung zu stellen. Somit bleibt es weiterhin möglich hier nach Lösungen zu suchen. Neue Beiträge können nicht mehr erstellt werden.

Wir empfehlen, für deine Fragen/Probleme Slack zu nutzen. Dort sind viele kompetente Benutzer aktiv und beantworten jegliche Fragen, gerne auch von REDAXO-Anfängern! Slack wird von uns sehr intensiv und meistens "rund um die Uhr" benutzt :-)
Selbst einladen kannst Du dich hier: https://redaxo.org/slack/
bluenote
Beiträge: 233
Registriert: 9. Mär 2006, 13:01

Teaser Problem

1. Jun 2010, 10:19

Moin moin zusammen.
Ich habe mir aus verschiedenen Modulen einen Teaser zusammengestrickt, der eigentlich ganz gut funktioniert. Leider baut er mir in die Ausgabe unerklärliche Auszeichnungen ein. Der geteaserte Text wird immer mit dem strong-Tag versehen, obwohl kein solches Element vorhanden ist.
Korrektur: Das Problem tritt konkret dann auf, wenn ich das Modul mehrfach verwende. Leider geht es nicht anders ich muss zwei verschiedene Kategorien anteasern.
Beispiel:
Aus:

Code: Alles auswählen

h1. Testartikel

Erster Absatz
Zweiter Absatz mit etwas Text. Bla bla bla
im textile wird:

Code: Alles auswählen

<div class="teaser"><strong>	</strong><h3><strong>Testartikel</strong></h3>

<strong>	</strong><p><strong>Erster Absatz<br>
Zweiter Absatz mit etwas Text. Bla bla bla</strong></p><strong><br><a class="more" href="/news-und-aktuelles/testartikel.html">...mehr lesen</a><br></strong></div>
Die Moduleingabe sieht so aus:

Code: Alles auswählen

<?php
// -- JQuery Teaser Modul --
// -- Andreas Otte        --
// -- otte@otte.net       --
// -- Version 1.0         --
// -------------------------
// -------------------------

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."&nbsp;&nbsp;");
         } else {
            add_cat_option( $child, $groupName."&nbsp;&nbsp;");
         }
      }
   }
}

function print_link($catName, $catId, $groupName) {
   global $selectedCat;
   if ( "REX_VALUE[1]" == $catId) {
      // selected
      echo "<option value=\"" . $catId . "\" selected>" . $groupName.$catName . "</option>\n";
   } else {
      echo "<option value=\"" . $catId . "\">" . $groupName.$catName . "</option>\n";
   }
}



?>
<table><tr>
   <td>Kategorie:</td>
   <td><select name="VALUE[1]">
   <?php PrintCategorieOptions(); ?>

   </select></td>
</tr>
<tr>
   <td>Textlänge:</td>
   <td><input type="text" size="50" name="VALUE[2]" value="REX_VALUE[2]" /></select></td>
</tr>
<tr>
   <td>Anzahl Artikel:</td>
   <td><input type="text" size="50" name="VALUE[4]" value="REX_VALUE[4]" /></select></td>
</tr>

<tr>
   <td>Sortieren nach:</td>
   <td><select  name="VALUE[5]">
   <option value="" <?php if("REX_VALUE[5]" == "") echo  'selected'; ?>>id</option>
   <option value="name" <?php if("REX_VALUE[5]" == "name") echo  'selected'; ?>>name</option>
   <option value="createdate" <?php if("REX_VALUE[5]" == "createdate") echo  'selected'; ?>>createdate</option>
   <option value="updatedate" <?php if("REX_VALUE[5]" == "updatedate") echo  'selected'; ?>>updatedate</option>
   <option value="online_from" <?php if("REX_VALUE[5]" == "online_from") echo  'selected'; ?>>online_from</option>
   <option value="online_to" <?php if("REX_VALUE[5]" == "online_to") echo  'selected'; ?>>online_to</option>
   <option value="prior" <?php if("REX_VALUE[5]" == "prior") echo  'selected'; ?>>Artikel-Prior</option>
   </select>
   <select  name="VALUE[6]">
   <option value="0" <?php if("REX_VALUE[6]" == "0") echo  'selected'; ?>>aufsteigend</option>
   <option value="1" <?php if("REX_VALUE[6]" == "1") echo  'selected'; ?>>absteigend</option>
   </select></td>
</tr>
</table>
Die Modulausgabe so:

Code: Alles auswählen

<div class="news">
<?php
// -- JQuery Teaser Modul --
// -- Andreas Otte        --
// -- otte@otte.net       --
// -- Version 1.0         --
// -------------------------
// -------------------------


if (!function_exists('truncate'))
{
 function truncate($string, $length = 80, $etc = '&nbsp;', $break_words = false)
 {
    if ($length == 0)
       return '';
    if (strlen($string) > $length)
    {
       $length -= strlen($etc);
       if (!$break_words)
          $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length +1));
       return substr($string, 0, $length).$etc;
    }
    else
       return $string;
 }
}

// 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;
 }
}

// 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;
 }
}


$catId = 'REX_VALUE[1]';
$lettersPerArticle = 'REX_VALUE[2]';
$sorting_order = 'CreateDate';
$mediaOut = '';

$itemsPerSide = "REX_VALUE[4]"; // Anzahl der News die gezeigt werden sollen

$cat = OOCategory::getCategoryById($catId);
$childs = $cat->getArticles( true);

if ( is_array( $childs)) {
 if('REX_VALUE[5]') {
    usort($childs, 'sortArticlesBy'.$sorting_order);
 }

  $counter = 1;
  foreach ( $childs as $child)
      {

    $id = $child->getId();

    // Startartikel ausblenden
    if ( $id == REX_VALUE[1]) continue;

    // Den aktuellen Artikel nicht verlinken
    if ($id == REX_ARTICLE_ID) continue;

$article = new article( $id);
// 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;
      }
$date = $child->getCreateDate();  // Erstellungs Datum
$media = $child->getFileMedia();  // Artikel Bild   

$content = truncate( $article->getArticle(), 'REX_VALUE[2]'); // Anzahl Zeichen
   
$find [] = '<h1>'; // finde h1
$find[] = '</h1>';
$replace[] = '<h3>'; // ersetze durch h3
$replace[] = '</h3>'; // kann für eigene Zwecke angepasst werden
$newcontent = str_replace($find, $replace, $content);
   
      
   // Ausgabe $out fuellen
    if($counter <= $itemsPerSide)
      {
     //print '<br/>';
      printf ('<div class="teaser">%s', $newcontent);
      if ($media != null)
          {
          $mediaOut .= '<p>';
          $mediaOut .= printf( '%s', $media->toHTML());
          $mediaOut .= print '</p>';
          }

      print '<br /><a class="more" href="'.$child->getUrl().'">...mehr lesen</a><br />';
      print '</div><!-- end teaser --><hr />';
      }
  $counter++; // wiederholen bis Anzahl der Artikel erreicht ist
  }
}
?>
 </div><!-- end news -->
Wäre schön, wenn sich das mal jemand ansehen könnte der im Gegensatz zu mir auch einen Plan hat ;-)
Danke.

Jens
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

Benutzeravatar
nitzer
Beiträge: 229
Registriert: 16. Okt 2006, 22:53
Wohnort: Erkrath
Kontaktdaten: ICQ Website

1. Jun 2010, 12:45

das liegt daran, daß in meinem teaser-modul html-tags nicht rausgefiltert werden. für meine anwendung war das so nötig.

ich habe einen teaser aus dem downloadbereich etwas modifiziert.

ursprungsversion ist diese hier:
http://www.redaxo.de/165-0-moduldetails ... dule_id=66

hier mein angepasster code:
- die kategoerie kann ausgewählt werden
- und die spalte (CType)

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);
		
		// 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="newsbox">'.$output.'</div>';
	}
}

$prevStart = $start - $offset;
if ( $prevStart < 0)
{
   $prevStart = '';
}


$nextStart = $start + $offset;
if ( $nextStart >= $articles_length)
{
   $nextStart = '';
}

$link_format = '<a href="'.rex_getUrl("15", $REX['CUR_CLANG'], array('start'=>'%s')).'">%s</a>';

// Vorherige Seite Link
if ( $prevStart !== '') {
  $backLink = sprintf( $link_format, $prevStart, '« '.$backLink_text);
}

// Nächste Seite
if ( $nextStart !== '') {
  $nextLink = sprintf( $link_format, $nextStart, $nextLink_text.' »');
}

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;
// print $catId;
?>
Vielleicht hilft das…

Grüße

Andreas

bluenote
Beiträge: 233
Registriert: 9. Mär 2006, 13:01

1. Jun 2010, 16:36

Vielen Dank für Deine Mühen. Das Modul funktioniert sehr gut und ist fast das was ich brauche. Leider wird on-/offline per Metadata nicht berücksichtigt, aber vielleicht kann ich das noch einbauen. Und wenn Du mir noch verrätst wo ich z.B. am besten eine h1 gegen eine h2 ersetzen lasse wäre ich Dir sehr dankbar.

Jens
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

Benutzeravatar
nitzer
Beiträge: 229
Registriert: 16. Okt 2006, 22:53
Wohnort: Erkrath
Kontaktdaten: ICQ Website

2. Jun 2010, 16:48

Naja, ich denke mal dass Dein Teaser in einem DIV steht, daher würde ich der H1 im Teaser über CSS die Styles von H1 aus dem normalen Content geben.

irgendwie so

#main h2, #teaser h1 {
/* hier dann die styles */
}

bluenote
Beiträge: 233
Registriert: 9. Mär 2006, 13:01

7. Jun 2010, 13:54

Ja, so kann man das natürlich auch machen.

Danke
Jens
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

bluenote
Beiträge: 233
Registriert: 9. Mär 2006, 13:01

Modulein- und ausgabe für Newsteaser

15. Jun 2010, 08:52

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&auml;chste Seite >>');
}

if ($backLink != "" AND $nextLink != "") {
	print '<div class="teaserNav"><p>'.$backLink.'&nbsp;|&nbsp;'.$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&ouml;&szlig;e des Artikelfotos</strong>:<br />
<input type="text" name="VALUE[5]" value="REX_VALUE[5]" size="30" class="inp100" />
<br />(w=Breite, h=H&ouml;he, a=die l&auml;ngere Seite, z.B.: 128w)
<br />
<hr>
<br />
<strong>Bitte Bilder f&uuml;r Galerie ausw&auml;hlen (Wenn es in diesen News keine Bilder gibt, einfach leerlassen):</strong>
<br />


			<strong>Bild(er) ausw&auml;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&ouml;&szlig;e Galeriebild</strong></td>
		<br/>
			<input type="text" style="width:70px;" name="VALUE[8]" value="REX_VALUE[8]" />
			<br />(w=Breite, h=H&ouml;he, a=die l&auml;ngere Seite, z.B.: 128w)
		<br/>
		<br/>
		<strong>CSS-Klasse f&uuml;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("###","&#x20;",$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>&laquo; <a href="'.$start_art->getUrl().'" title="Zur&uuml;ck zur &Uuml;bersicht">Zur&uuml;ck zur &Uuml;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
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

Zurück zu „Allgemeines [R4]“