[phpBB Debug] PHP Warning: in file [ROOT]/ext/tas2580/seourls/event/listener.php on line 213: Undefined array key "FORUM_NAME"
Online von bis Abfrage in Modul [gelöst] - 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

Online von bis Abfrage in Modul [gelöst]

27. Jan 2010, 16:38

Das jquery Teaser Accordion (http://www.redaxo.de/165-0-moduldetails ... ule_id=451) berücksichtigt zwar den on/offline Status von Artikeln, aber nicht, wenn diese über die Metainfos online oder offline geschaltet sind.
Ich würde nun gern diesen Status abfragen um Artikel auch zeitgesteuert anzeigen zu können.
Geeignet scheint mir z. B.

Code: Alles auswählen

(getValue('online_from') und getValue('online_to')
Verheiraten müsste man es wohl mit diesem Teil aus dem genannten Modul

Code: Alles auswählen

$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();
Tja, da verließen sie mich. Wie ersetze ich den Bereich

Code: Alles auswählen

getArticles( true);
in funktionsfähiger Weise mit meinem Schnipsel? Wenn ich denn nicht völlig auf dem Holzweg bin.

Jens
Zuletzt geändert von bluenote am 16. Feb 2010, 14:22, insgesamt 3-mal geändert.
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

Joachim.Dörr
Beiträge: 1403
Registriert: 7. Apr 2006, 01:49
Kontaktdaten: ICQ Website

28. Jan 2010, 09:11

Der "Online / Offline" - Status wird ja durch diese Datums Eingabe nicht beeinträchtigt. Deswegen hilft es nicht die Statusbezogene abfrage "$cat->getArticles(true);" anzufassen. Dein Part sollte später kommen in der Schleife in welcher der Artikel dann ausgelesen und angezeigt wird. Dort müsstest du die entsprechenden Metadaten checken welche den Zeitraum von bis definieren und prüfen ob die Ausgabe stattfinden kann oder nicht.

lg
Joachim

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

28. Jan 2010, 12:36

OK, erst Abfrage ob Status on- oder offline dann später erneute Abfrage ob via Zeitraum on-/offline geschaltet? Ich hab's mal so probiert, krieg jetzt aber nichts mehr ausgegeben, auch keine Fehlermeldung (na wenigstens das).
Was geht da nicht?
Wäre wirklich schön, wenn jemand weiterhelfen könnte, ich hänge echt fest.

Danke
Jens

Code: Alles auswählen

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


if (!function_exists('truncate'))
{
 function truncate($string, $length = 80, $etc = '...', $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);
$date = $child->getCreateDate();  // Erstellungs Datum
$media = $child->getFileMedia();  // Artikel Bild

$content = truncate( $article->getArticle(), 'REX_VALUE[2]'); // Anzahl Zeichen

$time = time(); 
 if($article->getValue('online_from') != $article->getValue('online_to'))
   {
      if($article->getValue('online_from') > $time || $article->getValue('online_to') < $time)
      {
         return;
      }
   } 

$find [] = '<h1>';
$find[] = '</h1>';
$replace[] = '<h3>';
$replace[] = '</h3>';
$newcontent = str_replace($find, $replace, $content); 
	
		
	// Ausgabe $out fuellen
    if($counter <= $itemsPerSide) 
      {
	  print '<hr/><br/>';
      printf ('<div>%s', $newcontent);
      if ($media != null)
          {
          $mediaOut .= '<p>';
          $mediaOut .= printf( '%s', $media->toHTML());
          $mediaOut .= print '</p>';
          }

      print '<a class="more" href="'.$child->getUrl().'">...mehr lesen</a><br />';
      print '</div></div>';
      }
  $counter++; // wiederholen bis Anzahl der srtikel erreicht ist
  }
}
?>
</div>

-- 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

29. Jan 2010, 11:16

OK, so wie ich es machen wollte soll es wohl nicht gehen. Hiermit

Code: Alles auswählen

if($time->getValue("online_from") != "" &&
   $var->getValue("online_from") > $time ||
   $var->getValue("online_to") != "" &&
   $var->getValue("online_to") < $time-86400)
statt

Code: Alles auswählen

$time = time();
 if($article->getValue('online_from') != $article->getValue('online_to'))
   {
      if($article->getValue('online_from') > $time || $article->getValue('online_to') < $time)
      {
         return;
      }
   } 
soll es gehen. Nur bekomme ich nur noch Fehler und weiß jetzt gar nicht mehr wie ich's einbauen soll.

Wäre klasse wenn mir jemand weiterhelfen könnte.

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

29. Jan 2010, 11:26

Hab noch was probiert und den Code mal so eingebaut:

Code: Alles auswählen

 ...ne Menge Code
$article = new article( $id);
$date = $child->getCreateDate();  // Erstellungs Datum
$media = $child->getFileMedia();  // Artikel Bild

if($article ->getValue("online_from") != "" &&
   $article ->getValue("online_from") > $time ||
   $article ->getValue("online_to") != "" &&
   $article ->getValue("online_to") < $time-86400)

$content = truncate( $article->getArticle(), 'REX_VALUE[2]'); // Anzahl Zeichen

$find [] = '<h1>';
$find[] = '</h1>';
$replace[] = '<h3>';
$replace[] = '</h3>';
$newcontent = str_replace($find, $replace, $content);
  
   // Ausgabe $out fuellen 
... noch ein wenig Code
Jetzt habe ich wenigstens keine Fehlermeldung mehr, aber die Ausgabe bleibt bis auf "mehr lesen" leer.
Hat bitte jemand eine Idee?

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

1. Feb 2010, 17:30

Hat denn keiner eine Idee wie das gehen könnte? Ich steh echt auf dem Schlauch.

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

3. Feb 2010, 14:18

Nach ewigem Probieren hab ich's jetzt selbst gefunden. Wer also ein Teasermodul sucht, welches Überschriften filtert und on-/offline aus den Metadaten berücksichtigt, sollte das jquery Teaser Accordion (http://www.redaxo.de/165-0-moduldetails ... ule_id=451) benutzen und den Code der Ausgabe durch folgenden ersetzen:

Code: Alles auswählen

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


if (!function_exists('truncate'))
{
 function truncate($string, $length = 80, $etc = '...', $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)
      {
         return;
      }
$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>%s', $newcontent);
      if ($media != null)
          {
          $mediaOut .= '<p>';
          $mediaOut .= printf( '%s', $media->toHTML());
          $mediaOut .= print '</p>';
          }

      print '<a class="more" href="'.$child->getUrl().'">...mehr lesen</a><br />';
      print '</div></div>';
      }
  $counter++; // wiederholen bis Anzahl der Artikel erreicht ist
  }
}
?>
</div>
Weil ich's nicht brauchte hab ich die Akkordion-Funktion weggelassen und auch die Ausgabe des Artikelnamens. Das lässt sich aber sicher leicht wieder einbauen.

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

Hey

3. Feb 2010, 17:01

Danke für Deinen Einsatz. Hab jetzt erst mitgelesen. Ich werd das mal zusammentragen und ein Update meines Moduls in den Download stellen. Vielleicht versuche ich eine Auswahlmöglichkeit für den User, damit das Teil flexibel bleibt und jeder das nach seinen Wünschen einstellen kann.

Grüße

Andreas

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

4. Feb 2010, 10:51

Daran hatte ich auch schon gedacht, nur leider sind meine PHP-Fähigkeiten fast gleich Null.
Wenn ich noch einen Vorschlag machen darf: ein Teaser mit einer Beschränkung der Wortanzahl statt Zeichenanzahl ist etwas schöner.

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

Benutzeravatar
Xong
Beiträge: 2081
Registriert: 5. Jun 2008, 08:30
Wohnort: Halle (Saale)

4. Feb 2010, 11:12

bluenote hat geschrieben:Wenn ich noch einen Vorschlag machen darf: ein Teaser mit einer Beschränkung der Wortanzahl statt Zeichenanzahl ist etwas schöner.
Da kann man aber die wirkliche Zeichenanzahl schlecht beeinflussen.

Für XSearch habe ich das so gelöst:

Code: Alles auswählen

function getTeaserText($_text, $_maxCharCount)
{
  $i = 0;
  $textArray = preg_split('~\s+~si', $_text, $_maxCharCount);
  
  $return = '';
  $aborted = false;
  foreach($textArray as $word)
  {
    if((($strlen = strlen($word)) + $i) > $_maxCharCount)
    {
      $aborted = true;
      break;
    }
    
    $return .= $word.' ';
    $i += $strlen + 1;
  }
  
  if($aborted)
    $return .= '…'; // Ellipse (= "...")
  
  return $return;
}
LG,
Xong

[ externes Bild ] Määääääääääääääääääääääääh!

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

4. Feb 2010, 12:59

Grade stelle ich fest das Artikel die ein Bild enthalten und per Zeitsteuerung offline sind, bewirken, dass gar keine Artikel mehr angezeigt werden. Der fragliche Artikel wurde mit dem "textile und/oder Bild" Modul erstellt.

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

16. Feb 2010, 14:21

Total blöder Fehler. Man muss im obigen Code

Code: Alles auswählen

...

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

...
nur das

Code: Alles auswählen

return
durch ein

Code: Alles auswählen

continue
ersetzen. Schon geht wieder alles.

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

rbildl
Beiträge: 11
Registriert: 23. Mär 2007, 14:11

26. Aug 2010, 09:47

Hallo, ich habe das Modul eingesetzt und es funktioniert eigentlich ganz gut.
Nun habe ich aber in meiner Template mehrere Spalten [CTYPES]. Wie bringe ich dieses Modul dazu, den Text einer bestimmten CTYPE ID zu teasern? Momentan wird bei mir der falsche CTYPE geteasert.

Schon mal vielen Dank,
rbildl

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

26. Aug 2010, 13:58

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&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;
?>
hth
Jens
-- Unser Kopf ist rund, damit das Denken die Richtung wechseln kann. Francis Picabia --
-- www.pixelBREEZER.de --

Zurück zu „Allgemeines [R4]“