Modul: Standard-Artikelliste Advanced V1.4

Mc
Beiträge: 188
Registriert: Mi 2. Mär 2005, 21:19
Kontaktdaten:

Beitrag von Mc »

Hallo HerrB,

vielen Dank. Funktioniert.
Gruß Mc
cschwan2006
Beiträge: 70
Registriert: Do 21. Sep 2006, 10:56
Kontaktdaten:

Umbau zum FAQ Modul

Beitrag von cschwan2006 »

Hallo HerrB,

und zwar habe ich folgendes Problem im umbau zum FAQ Modul:

Ich habe im Modul Out und Imput hinzugefügt das es mir erstmal nur die Kategorien ausgibt. (Ordner Ansicht)

Jetzt will ich aber nur die Ordner angezeigt haben die im nur die Erste Ebende
Darstellen z.B

FAQ
- Test 1
- Test 2
....
-Test 8

zur zeit zeigt er mir aber alle an

FAQ
- Test 1
- Test 1.1
- Test 1.1.1
- Test 1.2
- Test 2

ich kann zwar die kategorien auch manuell auswählen, aber da wäre ja zu einfach :D

Nächstes problem:
Wenn ich jetzt auf Test 1.1 gehe möchte ich gern das es mir die nur Kategorie in Order Ansicht Test 1.1.1 ausgibt und die artikel zu Test 1.1

Kannst du mir vielleicht einen anstoss geben wie man das umsetzten kann?

Gruss

Christian
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

ich kann zwar die kategorien auch manuell auswählen, aber da wäre ja zu einfach
Folgendes kann funktionieren, wenn nicht, bleibt Dir die einfache Variante...:

Die Lösung ist sehr speziell für die Anforderung, das sollte also ein neues Modul werden. Nur für den Zweck musst Du aus der con_tree ermitteln, welchen Level die Kategorie FAQ aufweist. Dann ergänzt Du im SQL-Statement zu "below"

Code: Alles auswählen

 AND (b.level = '<Level von FAQ>' OR b.level = '<Level von FAQ + 1>')
Ungetestet.
Wenn ich jetzt auf Test 1.1 gehe möchte ich gern das es mir die nur Kategorie in Order Ansicht Test 1.1.1 ausgibt und die artikel zu Test 1.1
Habe ich nicht verstanden. Wenn man bei Klick auf Test 1.1 zu Test 1.1.1 gelangen soll, musst Du im Startartikel eine Weiterleitung definieren. Wenn in Test 1.1 die Artikel aus Test 1.1 und Test 1.1.1 angezeigt werden sollen, musst Du halt in der Konfiguration in Test 1.1 (unter Verwendung eines "normalen" Artikelliste-Advanced-Moduls) sowohl die Kategorie Test 1.1, als auch Test 1.1.1 auswählen.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
cschwan2006
Beiträge: 70
Registriert: Do 21. Sep 2006, 10:56
Kontaktdaten:

Beitrag von cschwan2006 »

Habe ich nicht verstanden. Wenn man bei Klick auf Test 1.1 zu Test 1.1.1 gelangen soll, musst Du im Startartikel eine Weiterleitung definieren. Wenn in Test 1.1 die Artikel aus Test 1.1 und Test 1.1.1 angezeigt werden sollen, musst Du halt in der Konfiguration in Test 1.1 (unter Verwendung eines "normalen" Artikelliste-Advanced-Moduls) sowohl die Kategorie Test 1.1, als auch Test 1.1.1 auswählen.
Hallo HerrB,

Erstmal danke für die schnelle Antwort, hat geklappt; vielen DANK :lol:


Ich meinte das so: Wenn ich auf Test 1.1 klick soll es mir die artikel anzeigen, also alle die ich unter Test 1.1 eingetragen habe!

Aber es soll auch auf der Test 1.1 also wie die ganzen Artikel gelistet werden, ganz oben stehen das in der Test 1.1 noch ein Kategorie gibt also die (Test 1.1.1)

Aber ich habe auch noch das problem das wenn ich nur die Kategorien anzeigen lassen will das er das wie gesagt foreacht tut? Also zeigt er mir das 10 mal an!

Gibts da ne möglichkeit das er nur einmal die Kat ausgibt,

Code: Alles auswählen

foreach ($aData as $aValue) {

 echo '   <div id="CatListing"><a href="'.$aValue["CatLink"].'">'.$aValue["Category"].'</a></div>', chr(10);
}
Hoffe ich habe es jetzt bisschen verständlicher erklärt :D

Gruss Christian
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Aber es soll auch auf der Test 1.1 also wie die ganzen Artikel gelistet werden, ganz oben stehen das in der Test 1.1 noch ein Kategorie gibt also die (Test 1.1.1)
Siehe meine vorherige Antwort:
Wenn in Test 1.1 die Artikel aus Test 1.1 und Test 1.1.1 angezeigt werden sollen, musst Du halt in der Konfiguration in Test 1.1 (unter Verwendung eines "normalen" Artikelliste-Advanced-Moduls) sowohl die Kategorie Test 1.1, als auch Test 1.1.1 auswählen.
Wenn Du dabei auch die Kategorie ausgibst, sollte die gewünschte Funktionalität erreicht werden.
Aber ich habe auch noch das problem das wenn ich nur die Kategorien anzeigen lassen will das er das wie gesagt foreacht tut? Also zeigt er mir das 10 mal an!
Das Modul ist nicht dazu gedacht - die Sortierung der Artikel ist auch unabhängig von den Kategorien (wie irgendwo erwähnt). Es kann daher sein, dass bei 10 Artikeln (aus 10 Kategorien) 10 unterschiedliche Bezeichnungen ausgegeben werden.

Du kannst folgendes Versuchen: In der Ausgabe gibt es diese Zeile:

Code: Alles auswählen

   // Sort by
   $sql .= "ORDER BY ";
Darunter folgende Zeile ergänzen:

Code: Alles auswählen

   $sql .= "CATART.idcat, ";
Das funktioniert aber nur, wenn die Unter-Kategorie immer später (höhere idcat), als die Oberkategorie hat. Ungetestet.

In der Ausgabe definierst Du eine Variable und fängst Dubletten ab:

Code: Alles auswählen

$sOldCategory = "";
foreach ($aData as $aValue) {
  if ($sOldCategory !== $aValue["Category"]) {
    $sOldCategory = $aValue["Category"];
    echo '   <div id="CatListing"><a href="'.$aValue["CatLink"].'">'.$aValue["Category"].'</a></div>', chr(10);
  }
}
Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
derSteffen
Beiträge: 847
Registriert: Mi 14. Dez 2005, 16:15
Wohnort: Königs Wusterhausen bei Berlin
Kontaktdaten:

Beitrag von derSteffen »

netmax hat geschrieben: Ich habe festgestellt, dass nur "volle" Seiten mit Artikeln als Navi-Link dargestellt werden. D.h: Bei 22 vorhandenen Artikeln und 10 Artikeln pro Seite werden unten nur 2 Seiten angeboten, die restlichen 2 Artikel befinden sich nicht im Zugriff.

Schuld daran ist die Berechnung der Seiten in der Ausgabe:

Code: Alles auswählen

$iPages = intval($lCount / $aSettings["ArticlePerPage"]);
Dies berücksichtigt nur den Integer der Division, also 22/10=2.

Wenn man nun unter jeder dieser Zeilen dies hier einfügt...

Code: Alles auswählen

if (($lCount % $aSettings["ArticlePerPage"])>0) $iPages++;
... klappt's auch mit den Restseiten.

LG
Marco
Kann es sein das dadurch aber auch immer eine Seit meht in der Navigation angezeit wird? Das heißt wenn ich 10 Artikel haben und es sollen pro Seite auch 10 angezeigt werden, dass in der Navigation dann steht Seite 1, 2 und wenn ich auf 2 klicke da ja selbstverständlich nichts drinn ist?

Wenn ja besteht dir Möglichkeit eine Abfrage zu machen?

MfG
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Die Änderung von

Code: Alles auswählen

$iPages = intval($lCount / $aSettings["ArticlePerPage"]); 
in

Code: Alles auswählen

$iPages = ceil($lCount / $aSettings["ArticlePerPage"]);
sollte reichen.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
derSteffen
Beiträge: 847
Registriert: Mi 14. Dez 2005, 16:15
Wohnort: Königs Wusterhausen bei Berlin
Kontaktdaten:

Beitrag von derSteffen »

Vielen Dank für die Antwort, leider ist das nicht so! Ich hatte das auch schon geändert. Ich verwende auch die Navigation von benja! Tritt den der Fehler bei der Standardversion nicht auf?
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Doch, der Fehler ist alt, aber ich hatte noch keine Zeit, ihn nochmal komplett zu analysieren und zu korrigieren.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
benja
Beiträge: 168
Registriert: Mi 31. Aug 2005, 10:54
Wohnort: Köln
Kontaktdaten:

Beitrag von benja »

hallo,

ich habe ein problem mit der liste und verstehe überhaupt nicht woran das liegen kann.
könnte das ein bug sein?

die liste ist bei mir mehrfach im einsatz. drei mal listet sie "alle unterhalb primärer" - 35 artikel zufällig auf. auf zwei seiten sollen nur 12 "ausgewählte" artikel angezeigt werden. es werden aber immer nur 11 angezeigt, beim 12. wird zwar das div welches mit ausgegeben wird im quellcode angezeigt, aber der rest des codes fehlt. wenn ich einen reload mache fehlt ein artikel an anderer stelle! wenn ich 13 anzeigen lasse sieht es genauso aus, es werden 12 angezeigt aber einer bleibt immer frei.
was ganz seltsam ist, ganz selten wird der artikel dann doch angezeigt (nach ca. 20x reload)!!!

die liste selber habe ich modifiziert, es werden nur bilder ausgegeben und nur startartikel. liegt es vielleicht daran?

ich kann auch einen link schicken falls das hilft - möchte aber die seite noch nicht veröffentlichen.

hat das schon mal jemand gehabt? oder kann mir jemand helfen?

lg
benja
donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Wo wird die Abfrage eingefügt?

Beitrag von donner_blitz »

Ich habe ein Problem mit diesem Codeschnipsel. An welcher Stelle wird dieser Code eingesetzt?

i-fekt hat geschrieben:

Code: Alles auswählen

#
#-----[ FIND ]------------------------------------------
#
  foreach ($aData as $aValue) {


#
#-----[ ADD, AFTER ]------------------------------------
#
   $datum = strtotime($aValue["Created"]);
   $tag = date("j",$datum);
   $monat = date("m",$datum);
   $jahr = date("Y",$datum);
   $monat = str_replace(
    array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'),
    array('. Januar ', '. Februar ', '. M&auml;rz ', '. April ', '. Mai ', '. Juni ', '. Juli ', '. August ', '. September ', '. Oktober ', '. November ', '. Dezember '),
   $monat
   );
   
#
#-----[ ADD, ANYWHERE ]----------------------------------
#
".$tag.$monat.$jahr."
Nun kannst du mit ".$tag.$monat.$jahr." das Datum ausgeben lassen. Es erscheint in der Form "10. Februar 2006". Natürlich kannst du es auch anders auslesen und ausgaben. ;)
Danke schon mal im Vorraus.
gruß donner_blitz
cschwan2006
Beiträge: 70
Registriert: Do 21. Sep 2006, 10:56
Kontaktdaten:

Re: Wo wird die Abfrage eingefügt?

Beitrag von cschwan2006 »

donner_blitz hat geschrieben:Ich habe ein Problem mit diesem Codeschnipsel. An welcher Stelle wird dieser Code eingesetzt?

i-fekt hat geschrieben:

Code: Alles auswählen

#
#-----[ FIND ]------------------------------------------
#
  foreach ($aData as $aValue) {


#
#-----[ ADD, AFTER ]------------------------------------
#
   $datum = strtotime($aValue["Created"]);
   $tag = date("j",$datum);
   $monat = date("m",$datum);
   $jahr = date("Y",$datum);
   $monat = str_replace(
    array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'),
    array('. Januar ', '. Februar ', '. M&auml;rz ', '. April ', '. Mai ', '. Juni ', '. Juli ', '. August ', '. September ', '. Oktober ', '. November ', '. Dezember '),
   $monat
   );
   
#
#-----[ ADD, ANYWHERE ]----------------------------------
#
".$tag.$monat.$jahr."
Nun kannst du mit ".$tag.$monat.$jahr." das Datum ausgeben lassen. Es erscheint in der Form "10. Februar 2006". Natürlich kannst du es auch anders auslesen und ausgaben. ;)
Danke schon mal im Vorraus.
Direkt unter

Code: Alles auswählen

       # Output data
      # Every output manipulation should be done here...
      # 
      # Base information:
      # $aSettings["Elements"]:       Number of expected, additional elements from each article
      # $aSettings["ArticlePerPage"]: Number of articles per page (0: show all)
      # $aSettings["k".$i]["ElementType"]:   Per Element: Type of Element: Text, Image or ExtractedImage
      # $aSettings["k".$i]["ElementWidth"]:  Per Element: Text length or image width (-> recycling ...)
      # $aSettings["k".$i]["ElementHeight"]: Per Element: Image width
      # 
      # Per article:
      # $aValue["Headline"]:          Content of article element specified as containing the headline information
      # $aValue["Link"]:              Relative link to get to the listed article
      # $aValue["LastModified"]:      Last modified date of the article
      # $aValue["Created"]:           Created date of the article
      # $aValue["Published"]:         Published date of the article
      # $aValue["Category"]:          Category name
      # 
      # Per article additional element:
      # $aValue["i".$i]["Value"]:      Text (only for text elements, otherwise "")
      # $aValue["i".$i]["WebPath"]:    HTTP... path to image
      # $aValue["i".$i]["ServerPath"]: /server/... path to image
      # $aValue["i".$i]["Width"]:      >Original< image width
      # $aValue["i".$i]["Height"]:     >Original< image height

      foreach ($aData as $aValue) {

weil das steht ja "FIND" also finde
#-----[ FIND ]------------------------------------------
#
foreach ($aData as $aValue) {

und dann Add after -> füge darunter den code hinzu!

und dann fügst du einfach das datum ein:

Code: Alles auswählen

echo '<div class="article_date">'."$tag$monat$jahr".'</div>', chr(10);
dann futzt das ganze!
donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Re: Wo wird die Abfrage eingefügt?

Beitrag von donner_blitz »

habe ich jetzt so eingefügt, aber es funktioniert nicht. Ich bekomme eine rote Anzeige im Output. Hier der gesamte Code

Code: Alles auswählen

  
<?php
# Initialization
$bDebug     = false;
$iDataStart = 20;
$lCount     = 0;

unset ($aData);
$aData = array();

# Base settings
unset ($aSettings);
$aSettings = array();
$aSettings["ArticleCount"]       = "CMS_VALUE[0]";
$aSettings["ArticlePerPage"]     = "CMS_VALUE[1]";
$aSettings["SortBy"]             = "CMS_VALUE[2]";
$aSettings["SortDir"]            = "CMS_VALUE[3]";
$aSettings["ShowStart"]          = "CMS_VALUE[4]";
$aSettings["Category"]           = "CMS_VALUE[5]";
$aSettings["HeadlineIdentifier"] = "CMS_VALUE[7]";
$aSettings["HeadlineLength"]     = "CMS_VALUE[8]";
$aSettings["Elements"]           = "CMS_VALUE[9]";
$aSettings["CatTypeSel"]         = "CMS_VALUE[10]";
$aSettings["AddCats"]            = "CMS_VALUE[11]";

# Checking base settings
if (!is_numeric($aSettings["ArticleCount"]) || $aSettings["ArticleCount"] < 0) {
   $aSettings["ArticleCount"] = 5;
}
if (!is_numeric($aSettings["ArticlePerPage"]) || $aSettings["ArticlePerPage"] < 0) {
   $aSettings["ArticlePerPage"] = 0; // Deactivating page browsing
}
if ($aSettings["ArticlePerPage"] == 0 || !is_numeric($_REQUEST["nextstep"])) {
   $_REQUEST["nextstep"] = 0;
}
if (!is_numeric($aSettings["Category"]) || $aSettings["Category"] <= 0) {
   $aSettings["Category"] = 0;
}
if (strlen($aSettings["HeadlineIdentifier"]) > 50) {
   $aSettings["HeadlineIdentifier"] = "";
}
if (!is_numeric($aSettings["HeadlineLength"]) || $aSettings["HeadlineLength"] < 0) {
   $aSettings["HeadlineLength"] = 0;
}
if (!is_numeric($aSettings["Elements"]) || $aSettings["Elements"] < 0) {
   $aSettings["Elements"] = 0;
}
if ($aSettings["CatTypeSel"] == "" || ($aSettings["AddCats"] == "" && $aSettings["CatTypeSel"] == "selected")) {
   $aSettings["CatTypeSel"] = "none";
}

# Detail settings
if ($aSettings["Elements"] > 0) {
   for ($i = 0; $i < $aSettings["Elements"]; $i++) {
      $iElementType       = $iDataStart + ($i * 5);
      $iElementIdentifier = $iElementType + 1;
      $iElementWidth      = $iElementType + 2;
      $iElementHeight     = $iElementType + 3;

      $aSettings["k".$i] = array();
      $aSettings["k".$i]["ElementType"]    = "CMS_VALUE[$iElementType]"; // Text, Image, ExtractedImage
      $aSettings["k".$i]["Identifier"]     = "CMS_VALUE[$iElementIdentifier]";
      $aSettings["k".$i]["ElementWidth"]   = "CMS_VALUE[$iElementWidth]"; // Textlength or ImageWidth
      $aSettings["k".$i]["ElementHeight"]  = "CMS_VALUE[$iElementHeight]";

      # Check detail settings
      if ($aSettings["k".$i]["ElementType"] == "") {
         $aSettings["k".$i]["ElementType"] == "Text";
      }
      if ($aSettings["k".$i]["ElementType"] == "Text") {
         $aSettings["ElementHeight"] = 0;
         if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] < 0) {
            $aSettings["k".$i]["ElementWidth"] = 50;
         }
      } else if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] <= 0 ||
                 !is_numeric($aSettings["k".$i]["ElementHeight"]) || $aSettings["k".$i]["ElementHeight"] <= 0) {
         $aSettings["k".$i]["ElementWidth"] = 0;
         $aSettings["k".$i]["ElementHeight"] = 0;
      }
      if (strlen($aSettings["Identifier"]) > 50) {
         $aSettings["Identifier"] = "";
      }
   }
}

unset ($iDataStart);
unset ($iElementType);
unset ($iElementIdentifier);
unset ($iElementWidth);
unset ($iElementHeight);

if ($aSettings["Category"] !== "0" && $aSettings["HeadlineIdentifier"] !== "") {
   if (!is_object($db2)) {
      $db2 = new DB_Contenido;
   }

   # Specifying search categories
   $sSelCats = "'".$aSettings["Category"]."'";
   # Adding categories "below" primary category
   switch ($aSettings["CatTypeSel"]) {
      case "below":
         $lCatLevel = -1;
         $sql  = "SELECT a.idcat AS idcat, b.level AS level FROM ".$cfg["tab"]["cat"]." a, ".$cfg["tab"]["cat_tree"]." b ";
         $sql .= "WHERE a.idcat = b.idcat ORDER BY b.idtree";

         $db2->query($sql);
         while($db2->next_record()) {
            if ($db2->f("idcat") == $aSettings["Category"]) {
               $lCatLevel = $db2->f("level");
            } else if ($lCatLevel > -1 && $db2->f("level") > $lCatLevel) {
               $sSelCats .= ",'".$db2->f("idcat")."'";
            } else if ($db2->f("level") <= $lCatLevel) {
               break;
            }
         }
         break;
      case "selected":
         $aCats = explode(",",$aSettings["AddCats"]);
         foreach ($aCats as $value) {
            if (is_numeric($value)) {
               $sSelCats .= ",'".$value."'";
            }
         }
         break;
      default:
   }

   $sql  = "SELECT tblData.value AS headline, ARTLANG.idart AS id, ARTLANG.lastmodified AS lastmodified, " ;
   $sql .= "ARTLANG.created AS created, ARTLANG.published AS published, CATLANG.name AS category, ";
   $sql .= "ARTLANG.idartlang AS idartlang, CATART.idcat AS idcat, CATART.idcatart AS idcatart FROM ";
   $sql .= $cfg["tab"]["cat_art"]." AS CATART, ";
   $sql .= $cfg["tab"]["art_lang"]." AS ARTLANG, ";
   $sql .= $cfg["tab"]["cat_lang"]." AS CATLANG, ";
   $sql .= $cfg["tab"]["content"]." AS tblData ";

   $sql .= "WHERE CATART.idcat IN (".$sSelCats.") AND ARTLANG.idlang = '".$lang."' ";
   $sql .= "AND tblData.idartlang = ARTLANG.idartlang ";
   $sql .= "AND CATLANG.idlang = ARTLANG.idlang ";
   $sql .= "AND CATLANG.idcat = CATART.idcat ";
   $sql .= "AND ARTLANG.idart = CATART.idart ";

   if ($aSettings["ShowStart"] != "enabled") {
      if ($cfg["is_start_compatible"] == true) {
         $sql .= "AND CATART.is_start = '0' ";
      } else {
         $sql .= "AND tblData.idartlang != CATLANG.startidartlang ";
      }
   }

   $sql .= "AND ARTLANG.online = '1' ";
   $sql .= "AND ".$aSettings["HeadlineIdentifier"]." ";

   // Sort by
   $sql .= "ORDER BY ";
   $sql .= $aSettings["SortBy"]." ".$aSettings["SortDir"]." ";

   // LIMIT
   if ($aSettings["ArticleCount"] > 0) {
      $sql .= "LIMIT 0, ".$aSettings["ArticleCount"];
   }

   // execute query
   $db2->query($sql);
   $lCount = $db2->num_rows();

   if ($lCount > 0) {
      if (!is_object($db3)) {
         $db3 = new DB_Contenido;
      }
      if (!is_object($db4)) {
         $db4 = new DB_Contenido;
      }
      if ($aSettings["ArticlePerPage"] > 0) {
         $lStartCount = $_REQUEST["nextstep"];
         $lEndCount   = $_REQUEST["nextstep"] + $aSettings["ArticlePerPage"];
         if ($lEndCount > $lCount) {
            $lEndCount = $lCount;
         }
      } else {
         $lStartCount = 0;
         $lEndCount   = $lCount;
      }

      $lRow = 0;
      $i    = 0;
      while ($db2->next_record()) {
         if ( $aSettings["ShowStart"] == "enabled" || 
             ($aSettings["ShowStart"] != "enabled" && $db2->f("idartlang") != $lStartIDArtLang)) {
            if ($lRow >= $lStartCount && $lRow < $lEndCount) {
               $aData[$i]                        = array();
               $aData[$i]["Category"]            = urldecode($db2->f("category"));
               $aData[$i]["Link"]                = $sess->url("front_content.php?idcat=".$db2->f("idcat")."&idart=".$db2->f("id"));;
               $aData[$i]["LastModified"]        = $db2->f("lastmodified");
               $aData[$i]["Created"]             = $db2->f("created");
               $aData[$i]["Published"]           = $db2->f("published");
               $sTmpValue = html_entity_decode(strip_tags(urldecode($db2->f('headline'))));
               if ($aSettings["HeadlineLength"] > 0 && strlen($sTmpValue) > $aSettings["HeadlineLength"]) {
                  # Cutting text but preserving words and entities
                  $sTmpValue = htmlentities(capiStrTrimAfterWord($sTmpValue, $aSettings["HeadlineLength"])."...");
               }
               $aData[$i]["Headline"] = $sTmpValue;

               if ($aSettings["Elements"] > 0) {
                  for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                     $aData[$i]["i".$k]               = array();
                     $aData[$i]["i".$k]["Value"]      = "";
                     $aData[$i]["i".$k]["ServerPath"] = "";
                     $aData[$i]["i".$k]["WebPath"]    = "";
                     $aData[$i]["i".$k]["Width"]      = 0;
                     $aData[$i]["i".$k]["Height"]     = 0;
                  }
               
                  $sql =  "SELECT tblData.value AS value, tblData.idtype AS idtype, tblData.typeid AS typeid FROM ";
                  $sql .= $cfg["tab"]["cat_art"]." AS tblCatArt, ";
                  $sql .= $cfg["tab"]["art_lang"]." AS tblArtLang, ";
                  $sql .= $cfg["tab"]["content"]." AS tblData ";
                  $sql .= "WHERE tblData.idartlang = tblArtLang.idartlang AND ";
                  $sql .= "tblArtLang.idlang = '".$lang."' AND ";
                  $sql .= "tblArtLang.idart = tblCatArt.idart AND ";
                  $sql .= "tblCatArt.idcatart = '".$db2->f("idcatart")."' AND (";
               
                  $sql_items = "";
                  for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                     if ($aSettings["k".$k]["Identifier"] != "") {
                        if ($sql_items != "") {
                           $sql_items .= " OR (".$aSettings["k".$k]["Identifier"].")";
                        } else {
                           $sql_items = "(".$aSettings["k".$k]["Identifier"].")";
                        }
                     }
                  }
                  $sql .= $sql_items.")";
                  
                  if ($bDebug) {
                     echo "<pre>".$sql."</pre>", chr(10);
                  }

                  // execute query
                  $db3->query($sql);
                  
                  while ($db3->next_record()) {
                     $sTypeIdentifier = "tblData.idtype = '".$db3->f('idtype')."' AND tblData.typeid = '".$db3->f('typeid')."'";
                     
                     # Note: The TypeIdentifier for one item may be the same as for another item.
                     #       Therefore, we are storing the content everywhere as needed
                     for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                        if ($sTypeIdentifier == $aSettings["k".$k]["Identifier"]) {
                           switch (TRUE) {
                              case ($aSettings["k".$k]["ElementType"] == "Image" || $aSettings["k".$k]["ElementType"] == "ExtractedImage"):
                                 $sql = "";
                                 if ($aSettings["k".$k]["ElementType"] == "Image") {
                                    $sql =  "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
                                    $sql .= "WHERE idupl = '".$db3->f('value')."'";
                                 } else {
                                    $sTmpValue = urldecode($db3->f('value'));
   
                                    $regEx = "/<img[^>]*?>.*?/i";
                                    $match = array ();
                                    preg_match($regEx, $sTmpValue, $match);
      
                                    $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
                                    $img = array ();
                                    preg_match($regEx, $match[0], $img);
                                    $img_src = preg_split("/\//", $img[0]);
                                    
                                    $img_name = $img_src[count($img_src) - 1];
                                    $img_name = preg_replace("/\"/", "", $img_name);
                                    #Don't know what is happening here, exactly...
                                    # $img_split = preg_split("/\./", $img_name);
                                    # $img_type = $img_split[count($img_split) - 1];
                                    # $img_split2 = preg_split("/_/", $img_split[0]);

                                    $name = strtolower($img_name);

                                    #Don't know what is happening here, exactly...
                                    #if (count($img_split2) > 1) {
                                    #   $img_x = $img_split2[count($img_split2) - 1];
                                    #   $img_y = $img_split2[count($img_split2) - 2];
    
                                    #   if (is_numeric($img_x) AND is_numeric($img_y)) {
                                    #      $suffix = "_".$img_x."_".$img_y.".".$img_type;
                                    #      $name = preg_replace("/$suffix/", "", $img_name);
                                    #      $name = $name.".[a-zA-Z]{3}";
                                    #   }
                                    #}
   
                                    if (strlen($name) > 0) {
                                       $sql =  "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
                                       $sql .= "WHERE LOWER(filename) = '$name'";
                                       // $sql .= "WHERE filename REGEXP '$name'"; // Old: for 'banner.jpg' 'merlin_banner.jpg' is also returned
                                    }
                                 }
                              
                                 if ($bDebug) {
                                    echo "<pre>".$sql."</pre>";
                                 }
                              
                                 // execute query
                                 if ($sql != "") {
                                    $db4->query($sql);
                                 
                                    if ($db4->next_record()) {
                                       $aData[$i]["i".$k]["ServerPath"] = $cfgClient[$client]["upl"]["path"].$db4->f('dirname').$db4->f('filename');
                                       $aData[$i]["i".$k]["WebPath"]    = $cfgClient[$client]["upl"]["htmlpath"].$db4->f('dirname').$db4->f('filename');

                                       list ($width, $height, $type, $attr) = getimagesize($aData[$i]["i".$k]["WebPath"]);
                                       $aData[$i]["i".$k]["Width"]      = $width;
                                       $aData[$i]["i".$k]["Height"]     = $height;
                                    }
                                 }
                              
                                 break;
                              default:
                                 $sTmpValue = html_entity_decode(strip_tags(urldecode($db3->f('value'))));
                                 if ($aSettings["k".$k]["ElementWidth"] > 0 && strlen($sTmpValue) > $aSettings["k".$k]["ElementWidth"]) {
                                    # Cutting text but preserving words and entities
                                    $sTmpValue = htmlentities(capiStrTrimAfterWord($sTmpValue, $aSettings["k".$k]["ElementWidth"])."...");
                                 }
                                 $aData[$i]["i".$k]["Value"] = $sTmpValue;
                           }
                        }
                     } 
                  }
               }
               $i++;
            } else if ($lRow == $lEndCount) {
               break;
            }
            $lRow++;
         }
      }
      # Clearing memory
      unset ($db2);
      unset ($db3);
      unset ($db4);
      unset ($sql);
      unset ($lStartIDArtLang);
      unset ($lStartCount);
      unset ($lEndCount);


# Output data 
      # Every output manipulation should be done here... 
      # 
      # Base information: 
      # $aSettings["Elements"]:       Number of expected, additional elements from each article 
      # $aSettings["ArticlePerPage"]: Number of articles per page (0: show all) 
      # $aSettings["k".$i]["ElementType"]:   Per Element: Type of Element: Text, Image or ExtractedImage 
      # $aSettings["k".$i]["ElementWidth"]:  Per Element: Text length or image width (-> recycling ...) 
      # $aSettings["k".$i]["ElementHeight"]: Per Element: Image width 
      # 
      # Per article: 
      # $aValue["Headline"]:          Content of article element specified as containing the headline information 
      # $aValue["Link"]:              Relative link to get to the listed article 
      # $aValue["LastModified"]:      Last modified date of the article 
      # $aValue["Created"]:           Created date of the article 
      # $aValue["Published"]:         Published date of the article 
      # $aValue["Category"]:          Category name 
      # 
      # Per article additional element: 
      # $aValue["i".$i]["Value"]:      Text (only for text elements, otherwise "") 
      # $aValue["i".$i]["WebPath"]:    HTTP... path to image 
      # $aValue["i".$i]["ServerPath"]: /server/... path to image 
      # $aValue["i".$i]["Width"]:      >Original< image width 
      # $aValue["i".$i]["Height"]:     >Original< image height 

# 
#-----[ FIND ]------------------------------------------ 
# 
  foreach ($aData as $aValue) { 


# 
#-----[ ADD, AFTER ]------------------------------------ 
# 
   $datum = strtotime($aValue["Created"]); 
   $tag = date("j",$datum); 
   $monat = date("m",$datum); 
   $jahr = date("Y",$datum); 
   $monat = str_replace( 
    array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'), 
    array('. Januar ', '. Februar ', '. M&auml;rz ', '. April ', '. Mai ', '. Juni ', '. Juli ', '. August ', '. September ', '. Oktober ', '. November ', '. Dezember '), 
   $monat 
   ); 
    
# 
#-----[ ADD, ANYWHERE ]---------------------------------- 
# 
".$tag.$monat.$jahr."




/* Init Template 
*/ 
$template_advanced = "teaser_advanced.html"; 
$template_advanced2 = "teaser_advanced_element.html"; 
$newsheadline = "Neues auf dieser Seite"; 
$ii = 0; 
if (!is_object($tpl)) { 
   $tpl = new Template; 
} 

$tpl->reset(); 
$tpl->set('s', 'TITLE', $newsheadline); 
      foreach ($aData as $aValue) { 
       $headline_advanced = $aValue["Category"].": ".$aValue["Headline"]; 
         if ($aSettings["Elements"] > 0) { 
            if (!is_object($tpl2)) {     #generate template for elements 
            $tpl2 = new Template; 
            } 
         $tpl2->reset(); 

            $img_number = 0; 
            $text_number = 0; 
            for ($i = 0; $i < $aSettings["Elements"]; $i++) { 
               switch (TRUE) { 
                  case ($aSettings["k".$i]["ElementType"] == "Image" || $aSettings["k".$i]["ElementType"] == "ExtractedImage"): 
                  if (!empty($aValue["i".$i]["WebPath"])) {     // modify oldperl: if no Webpath, there's no image 
                     $image = $aValue["i".$i]["WebPath"]; 

                     $width  = $aValue["i".$i]["Width"]; 
                     $height = $aValue["i".$i]["Height"]; 

                     if ($aSettings["k".$i]["ElementWidth"] > 0 && $aSettings["k".$i]["ElementHeight"] > 0) { 
                        # Check, if resize necessary 
                        if ($aValue["i".$i]["ServerPath"] != "" && file_exists($aValue["i".$i]["ServerPath"]) && 
                            ($aValue["i".$i]["Width"] > $aSettings["k".$i]["ElementWidth"] || 
                             $aValue["i".$i]["Height"] > $aSettings["k".$i]["ElementHeight"])) { 
                           # Scale image 
                           $image = capiImgScale($aValue["i".$i]["ServerPath"], $aSettings["k".$i]["ElementWidth"], $aSettings["k".$i]["ElementHeight"], false, false, 10, false); 

                           #Get dimensions of the image 
                           list ($width, $height, $type, $attr) = getimagesize($image); 
                        } else { 
                           $image = $aValue["i".$i]["WebPath"]; 

                           $width  = $aValue["i".$i]["Width"]; 
                           $height = $aValue["i".$i]["Height"]; 
                        } 
                     } 

                     if ($image != "") { 
                        $element_class = 'img_advanced'.$img_number; 
                        if ($XHTML == true) { 
                        $element_content = '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="" />';                      } else { 
                        $element_content = '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="">'; 
                        } 

                        $img_number++; 
                     } 
                     } else {       // modify oldperl: if no image, we need no template 
                        $no_template = true; 
                     } 
                     break; 
                  default: // Everything else is treated as "Text" 
                     $element_class = 'text_advanced'.$text_number;  // set the class-value for div 
                     $element_content = $aValue["i".$i]["Value"]; // set content for div 

                     $text_number++; 
               } 
                  if(!$no_template) {     // modify oldperl: build tpl only if needed 
                   // build elements with template 
                   $tpl2->set('d', 'CLASS_ELEMENT', $element_class); 
                   $tpl2->set('d', 'CONTENT_ELEMENT',$element_content); 
                   $tpl2->next(); 
                } else { 
                   $no_template = false; 
                } 
            } 


            $content_elements = $tpl2->generate('templates/'.$template_advanced2, true);  // save tpl with elements for printing with master-tpl 
         } 
         if ($XHTML == true) { 
         $sign_img = '';
         } else { 
         $sign_img = '';
         } 
         $show_more = '<a href="'.$aValue["Link"].'">'.mi18n("More...").'</a>'; 


         $tpl->set('d', 'HEADLINE', $headline_advanced); 
         $tpl->set('d', 'COUNT', ($ii % 2));  // Variable füllen für CSS-Class teaser_advanced 
         $tpl->set('d', 'CONTENT',  $content_elements); 
         $tpl->set('d', 'MORE', $show_more); 
         $tpl->set('d', 'SIGN_MORE', $sign_more); 


       $tpl->next(); 
       $ii++; // Variable hochzählen  für CSS-Class teaser_advanced 
      } 
   } 

   # Page browsing 
   # Hint: Number of max available records: $lCount 
   #       Number of pages: round($lCount / $aSettings["ArticlePerPage"]) 
   #       First page: nextstep=0 
   #       Last page:  nextstep=(round($lCount / $aSettings["ArticlePerPage"]) - 1) * $aSettings["ArticlePerPage"]; 
   #                   (I have to admit that I'm not sure about the last page formula ... ;-) ) 
   if ($aSettings["ArticlePerPage"] > 0) { 

      # Example: |< 1 ... 3 4 5 ... 8 >| 
      $iPages = ceil($lCount / $aSettings["ArticlePerPage"]); 
      $sPageBack = ''; 
      $sPageLinks = ''; 
      $sPageForward = ''; 

      $sPageBack = '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep=0">|<</a>'; 
      for ($i = 1; $i <= $iPages; $i++) { 
         $lNextStep = ($i - 1) * $aSettings["ArticlePerPage"]; 
         if ($i == 1 || $i == $iPages) { 
            if ($sPageLinks != '') { 
               $sPageLinks .= '&nbsp;'; 
            } 
            if ($_REQUEST["nextstep"] == $lNextStep) { 
               $sPageLinks .= $i; # I'm on the current page, no link 
            } else { 
               $sPageLinks .= '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>'; 
            } 
         } else if ($_REQUEST["nextstep"] == $lNextStep) { 
            $sPageLinks .= '&nbsp;'.$i; # I'm on the current page, no link 
         } else if ($_REQUEST["nextstep"] == ($lNextStep + $aSettings["ArticlePerPage"])) { 
            # Front 
            $sPageLinks .= '&nbsp;<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>'; 
         } else if ($_REQUEST["nextstep"] == ($lNextStep - $aSettings["ArticlePerPage"])) { 
            # Back 
            $sPageLinks .= '&nbsp;<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>'; 
         } else if ($_REQUEST["nextstep"] == ($lNextStep - (2 * $aSettings["ArticlePerPage"])) || 
                    $_REQUEST["nextstep"] == ($lNextStep + (2 * $aSettings["ArticlePerPage"]))) { 
            $sPageLinks .= '...'; 
         } 
      } 

      $sPageForward = '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.(ceil($lCount / $aSettings["ArticlePerPage"]) - 1) * $aSettings["ArticlePerPage"].'">>|</a>'."\n"; 

   } 
   $tpl->set('s', 'BACK', $sPageBack); 
   $tpl->set('s', 'PAGESELECTOR', $sPageLinks); 
   $tpl->set('s', 'FORWARD', $sPageForward); 

   $tpl->generate('templates/'.$template_advanced); 
} 
# Clearing memory 
unset ($aData); 
unset ($aSettings); 
unset ($i); 
unset ($lCount); 
unset ($bDebug); 
?>
gruß donner_blitz
cschwan2006
Beiträge: 70
Registriert: Do 21. Sep 2006, 10:56
Kontaktdaten:

Re: Wo wird die Abfrage eingefügt?

Beitrag von cschwan2006 »

das ist total falsch;-)

hier der richtige code!

Code: Alles auswählen

<?php
# Initialization
$bDebug     = false;
$iDataStart = 20;
$lCount     = 0;

unset ($aData);
$aData = array();

# Base settings
unset ($aSettings);
$aSettings = array();
$aSettings["ArticleCount"]       = "CMS_VALUE[0]";
$aSettings["ArticlePerPage"]     = "CMS_VALUE[1]";
$aSettings["SortBy"]             = "CMS_VALUE[2]";
$aSettings["SortDir"]            = "CMS_VALUE[3]";
$aSettings["ShowStart"]          = "CMS_VALUE[4]";
$aSettings["Category"]           = "CMS_VALUE[5]";
$aSettings["HeadlineIdentifier"] = "CMS_VALUE[7]";
$aSettings["HeadlineLength"]     = "CMS_VALUE[8]";
$aSettings["Elements"]           = "CMS_VALUE[9]";
$aSettings["CatTypeSel"]         = "CMS_VALUE[10]";
$aSettings["AddCats"]            = "CMS_VALUE[11]";

# Checking base settings
if (!is_numeric($aSettings["ArticleCount"]) || $aSettings["ArticleCount"] < 0) {
   $aSettings["ArticleCount"] = 5;
}
if (!is_numeric($aSettings["ArticlePerPage"]) || $aSettings["ArticlePerPage"] < 0) {
   $aSettings["ArticlePerPage"] = 0; // Deactivating page browsing
}
if ($aSettings["ArticlePerPage"] == 0 || !is_numeric($_REQUEST["nextstep"])) {
   $_REQUEST["nextstep"] = 0;
}
if (!is_numeric($aSettings["Category"]) || $aSettings["Category"] <= 0) {
   $aSettings["Category"] = 0;
}
if (strlen($aSettings["HeadlineIdentifier"]) > 50) {
   $aSettings["HeadlineIdentifier"] = "";
}
if (!is_numeric($aSettings["HeadlineLength"]) || $aSettings["HeadlineLength"] < 0) {
   $aSettings["HeadlineLength"] = 0;
}
if (!is_numeric($aSettings["Elements"]) || $aSettings["Elements"] < 0) {
   $aSettings["Elements"] = 0;
}
if ($aSettings["CatTypeSel"] == "" || ($aSettings["AddCats"] == "" && $aSettings["CatTypeSel"] == "selected")) {
   $aSettings["CatTypeSel"] = "none";
}

# Detail settings
if ($aSettings["Elements"] > 0) {
   for ($i = 0; $i < $aSettings["Elements"]; $i++) {
      $iElementType       = $iDataStart + ($i * 5);
      $iElementIdentifier = $iElementType + 1;
      $iElementWidth      = $iElementType + 2;
      $iElementHeight     = $iElementType + 3;

      $aSettings["k".$i] = array();
      $aSettings["k".$i]["ElementType"]    = "CMS_VALUE[$iElementType]"; // Text, Image, ExtractedImage
      $aSettings["k".$i]["Identifier"]     = "CMS_VALUE[$iElementIdentifier]";
      $aSettings["k".$i]["ElementWidth"]   = "CMS_VALUE[$iElementWidth]"; // Textlength or ImageWidth
      $aSettings["k".$i]["ElementHeight"]  = "CMS_VALUE[$iElementHeight]";

      # Check detail settings
      if ($aSettings["k".$i]["ElementType"] == "") {
         $aSettings["k".$i]["ElementType"] == "Text";
      }
      if ($aSettings["k".$i]["ElementType"] == "Text") {
         $aSettings["ElementHeight"] = 0;
         if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] < 0) {
            $aSettings["k".$i]["ElementWidth"] = 50;
         }
      } else if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] <= 0 ||
                 !is_numeric($aSettings["k".$i]["ElementHeight"]) || $aSettings["k".$i]["ElementHeight"] <= 0) {
         $aSettings["k".$i]["ElementWidth"] = 0;
         $aSettings["k".$i]["ElementHeight"] = 0;
      }
      if (strlen($aSettings["Identifier"]) > 50) {
         $aSettings["Identifier"] = "";
      }
   }
}

unset ($iDataStart);
unset ($iElementType);
unset ($iElementIdentifier);
unset ($iElementWidth);
unset ($iElementHeight);

if ($aSettings["Category"] !== "0" && $aSettings["HeadlineIdentifier"] !== "") {
   if (!is_object($db2)) {
      $db2 = new DB_Contenido;
   }

   # Specifying search categories
   $sSelCats = "'".$aSettings["Category"]."'";
   # Adding categories "below" primary category
   switch ($aSettings["CatTypeSel"]) {
      case "below":
         $lCatLevel = -1;
         $sql  = "SELECT a.idcat AS idcat, b.level AS level FROM ".$cfg["tab"]["cat"]." a, ".$cfg["tab"]["cat_tree"]." b ";
         $sql .= "WHERE a.idcat = b.idcat ORDER BY b.idtree";

         $db2->query($sql);
         while($db2->next_record()) {
            if ($db2->f("idcat") == $aSettings["Category"]) {
               $lCatLevel = $db2->f("level");
            } else if ($lCatLevel > -1 && $db2->f("level") > $lCatLevel) {
               $sSelCats .= ",'".$db2->f("idcat")."'";
            } else if ($db2->f("level") <= $lCatLevel) {
               break;
            }
         }
         break;
      case "selected":
         $aCats = explode(",",$aSettings["AddCats"]);
         foreach ($aCats as $value) {
            if (is_numeric($value)) {
               $sSelCats .= ",'".$value."'";
            }
         }
         break;
      default:
   }

   $sql  = "SELECT tblData.value AS headline, ARTLANG.idart AS id, ARTLANG.lastmodified AS lastmodified, " ;
   $sql .= "ARTLANG.created AS created, ARTLANG.published AS published, CATLANG.name AS category, ";
   $sql .= "ARTLANG.idartlang AS idartlang, CATART.idcat AS idcat, CATART.idcatart AS idcatart FROM ";
   $sql .= $cfg["tab"]["cat_art"]." AS CATART, ";
   $sql .= $cfg["tab"]["art_lang"]." AS ARTLANG, ";
   $sql .= $cfg["tab"]["cat_lang"]." AS CATLANG, ";
   $sql .= $cfg["tab"]["content"]." AS tblData ";

   $sql .= "WHERE CATART.idcat IN (".$sSelCats.") AND ARTLANG.idlang = '".$lang."' ";
   $sql .= "AND tblData.idartlang = ARTLANG.idartlang ";
   $sql .= "AND CATLANG.idlang = ARTLANG.idlang ";
   $sql .= "AND CATLANG.idcat = CATART.idcat ";
   $sql .= "AND ARTLANG.idart = CATART.idart ";

   if ($aSettings["ShowStart"] != "enabled") {
      if ($cfg["is_start_compatible"] == true) {
         $sql .= "AND CATART.is_start = '0' ";
      } else {
         $sql .= "AND tblData.idartlang != CATLANG.startidartlang ";
      }
   }

   $sql .= "AND ARTLANG.online = '1' ";
   $sql .= "AND ".$aSettings["HeadlineIdentifier"]." ";

   // Sort by
   $sql .= "ORDER BY ";
   $sql .= $aSettings["SortBy"]." ".$aSettings["SortDir"]." ";

   // LIMIT
   if ($aSettings["ArticleCount"] > 0) {
      $sql .= "LIMIT 0, ".$aSettings["ArticleCount"];
   }

   // execute query
   $db2->query($sql);
   $lCount = $db2->num_rows();

   if ($lCount > 0) {
      if (!is_object($db3)) {
         $db3 = new DB_Contenido;
      }
      if (!is_object($db4)) {
         $db4 = new DB_Contenido;
      }
      if ($aSettings["ArticlePerPage"] > 0) {
         $lStartCount = $_REQUEST["nextstep"];
         $lEndCount   = $_REQUEST["nextstep"] + $aSettings["ArticlePerPage"];
         if ($lEndCount > $lCount) {
            $lEndCount = $lCount;
         }
      } else {
         $lStartCount = 0;
         $lEndCount   = $lCount;
      }

      $lRow = 0;
      $i    = 0;
      while ($db2->next_record()) {
         if ( $aSettings["ShowStart"] == "enabled" ||
             ($aSettings["ShowStart"] != "enabled" && $db2->f("idartlang") != $lStartIDArtLang)) {
            if ($lRow >= $lStartCount && $lRow < $lEndCount) {
               $aData[$i]                        = array();
               $aData[$i]["Category"]            = urldecode($db2->f("category"));
               $aData[$i]["Link"]                = $sess->url("front_content.php?idcat=".$db2->f("idcat")."&idart=".$db2->f("id"));;
               $aData[$i]["LastModified"]        = $db2->f("lastmodified");
               $aData[$i]["Created"]             = $db2->f("created");
               $aData[$i]["Published"]           = $db2->f("published");
               $sTmpValue = html_entity_decode(strip_tags(urldecode($db2->f('headline'))));
               if ($aSettings["HeadlineLength"] > 0 && strlen($sTmpValue) > $aSettings["HeadlineLength"]) {
                  # Cutting text but preserving words and entities
                  $sTmpValue = htmlentities(capiStrTrimAfterWord($sTmpValue, $aSettings["HeadlineLength"])."...");
               }
               $aData[$i]["Headline"] = $sTmpValue;

               if ($aSettings["Elements"] > 0) {
                  for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                     $aData[$i]["i".$k]               = array();
                     $aData[$i]["i".$k]["Value"]      = "";
                     $aData[$i]["i".$k]["ServerPath"] = "";
                     $aData[$i]["i".$k]["WebPath"]    = "";
                     $aData[$i]["i".$k]["Width"]      = 0;
                     $aData[$i]["i".$k]["Height"]     = 0;
                  }
               
                  $sql =  "SELECT tblData.value AS value, tblData.idtype AS idtype, tblData.typeid AS typeid FROM ";
                  $sql .= $cfg["tab"]["cat_art"]." AS tblCatArt, ";
                  $sql .= $cfg["tab"]["art_lang"]." AS tblArtLang, ";
                  $sql .= $cfg["tab"]["content"]." AS tblData ";
                  $sql .= "WHERE tblData.idartlang = tblArtLang.idartlang AND ";
                  $sql .= "tblArtLang.idlang = '".$lang."' AND ";
                  $sql .= "tblArtLang.idart = tblCatArt.idart AND ";
                  $sql .= "tblCatArt.idcatart = '".$db2->f("idcatart")."' AND (";
               
                  $sql_items = "";
                  for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                     if ($aSettings["k".$k]["Identifier"] != "") {
                        if ($sql_items != "") {
                           $sql_items .= " OR (".$aSettings["k".$k]["Identifier"].")";
                        } else {
                           $sql_items = "(".$aSettings["k".$k]["Identifier"].")";
                        }
                     }
                  }
                  $sql .= $sql_items.")";
                 
                  if ($bDebug) {
                     echo "<pre>".$sql."</pre>", chr(10);
                  }

                  // execute query
                  $db3->query($sql);
                 
                  while ($db3->next_record()) {
                     $sTypeIdentifier = "tblData.idtype = '".$db3->f('idtype')."' AND tblData.typeid = '".$db3->f('typeid')."'";
                     
                     # Note: The TypeIdentifier for one item may be the same as for another item.
                     #       Therefore, we are storing the content everywhere as needed
                     for ($k = 0; $k < $aSettings["Elements"]; $k++) {
                        if ($sTypeIdentifier == $aSettings["k".$k]["Identifier"]) {
                           switch (TRUE) {
                              case ($aSettings["k".$k]["ElementType"] == "Image" || $aSettings["k".$k]["ElementType"] == "ExtractedImage"):
                                 $sql = "";
                                 if ($aSettings["k".$k]["ElementType"] == "Image") {
                                    $sql =  "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
                                    $sql .= "WHERE idupl = '".$db3->f('value')."'";
                                 } else {
                                    $sTmpValue = urldecode($db3->f('value'));
   
                                    $regEx = "/<img[^>]*?>.*?/i";
                                    $match = array ();
                                    preg_match($regEx, $sTmpValue, $match);
     
                                    $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
                                    $img = array ();
                                    preg_match($regEx, $match[0], $img);
                                    $img_src = preg_split("/\//", $img[0]);
                                   
                                    $img_name = $img_src[count($img_src) - 1];
                                    $img_name = preg_replace("/\"/", "", $img_name);
                                    #Don't know what is happening here, exactly...
                                    # $img_split = preg_split("/\./", $img_name);
                                    # $img_type = $img_split[count($img_split) - 1];
                                    # $img_split2 = preg_split("/_/", $img_split[0]);

                                    $name = strtolower($img_name);

                                    #Don't know what is happening here, exactly...
                                    #if (count($img_split2) > 1) {
                                    #   $img_x = $img_split2[count($img_split2) - 1];
                                    #   $img_y = $img_split2[count($img_split2) - 2];
   
                                    #   if (is_numeric($img_x) AND is_numeric($img_y)) {
                                    #      $suffix = "_".$img_x."_".$img_y.".".$img_type;
                                    #      $name = preg_replace("/$suffix/", "", $img_name);
                                    #      $name = $name.".[a-zA-Z]{3}";
                                    #   }
                                    #}
   
                                    if (strlen($name) > 0) {
                                       $sql =  "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
                                       $sql .= "WHERE LOWER(filename) = '$name'";
                                       // $sql .= "WHERE filename REGEXP '$name'"; // Old: for 'banner.jpg' 'merlin_banner.jpg' is also returned
                                    }
                                 }
                             
                                 if ($bDebug) {
                                    echo "<pre>".$sql."</pre>";
                                 }
                             
                                 // execute query
                                 if ($sql != "") {
                                    $db4->query($sql);
                                 
                                    if ($db4->next_record()) {
                                       $aData[$i]["i".$k]["ServerPath"] = $cfgClient[$client]["upl"]["path"].$db4->f('dirname').$db4->f('filename');
                                       $aData[$i]["i".$k]["WebPath"]    = $cfgClient[$client]["upl"]["htmlpath"].$db4->f('dirname').$db4->f('filename');

                                       list ($width, $height, $type, $attr) = getimagesize($aData[$i]["i".$k]["WebPath"]);
                                       $aData[$i]["i".$k]["Width"]      = $width;
                                       $aData[$i]["i".$k]["Height"]     = $height;
                                    }
                                 }
                             
                                 break;
                              default:
                                 $sTmpValue = html_entity_decode(strip_tags(urldecode($db3->f('value'))));
                                 if ($aSettings["k".$k]["ElementWidth"] > 0 && strlen($sTmpValue) > $aSettings["k".$k]["ElementWidth"]) {
                                    # Cutting text but preserving words and entities
                                    $sTmpValue = htmlentities(capiStrTrimAfterWord($sTmpValue, $aSettings["k".$k]["ElementWidth"])."...");
                                 }
                                 $aData[$i]["i".$k]["Value"] = $sTmpValue;
                           }
                        }
                     }
                  }
               }
               $i++;
            } else if ($lRow == $lEndCount) {
               break;
            }
            $lRow++;
         }
      }
      # Clearing memory
      unset ($db2);
      unset ($db3);
      unset ($db4);
      unset ($sql);
      unset ($lStartIDArtLang);
      unset ($lStartCount);
      unset ($lEndCount);


# Output data
      # Every output manipulation should be done here...
      #
      # Base information:
      # $aSettings["Elements"]:       Number of expected, additional elements from each article
      # $aSettings["ArticlePerPage"]: Number of articles per page (0: show all)
      # $aSettings["k".$i]["ElementType"]:   Per Element: Type of Element: Text, Image or ExtractedImage
      # $aSettings["k".$i]["ElementWidth"]:  Per Element: Text length or image width (-> recycling ...)
      # $aSettings["k".$i]["ElementHeight"]: Per Element: Image width
      #
      # Per article:
      # $aValue["Headline"]:          Content of article element specified as containing the headline information
      # $aValue["Link"]:              Relative link to get to the listed article
      # $aValue["LastModified"]:      Last modified date of the article
      # $aValue["Created"]:           Created date of the article
      # $aValue["Published"]:         Published date of the article
      # $aValue["Category"]:          Category name
      #
      # Per article additional element:
      # $aValue["i".$i]["Value"]:      Text (only for text elements, otherwise "")
      # $aValue["i".$i]["WebPath"]:    HTTP... path to image
      # $aValue["i".$i]["ServerPath"]: /server/... path to image
      # $aValue["i".$i]["Width"]:      >Original< image width
      # $aValue["i".$i]["Height"]:     >Original< image height


   

/* Init Template
*/
$template_advanced = "teaser_advanced.html";
$template_advanced2 = "teaser_advanced_element.html";
$newsheadline = "Neues auf dieser Seite";
$ii = 0;
if (!is_object($tpl)) {
   $tpl = new Template;
}

$tpl->reset();
$tpl->set('s', 'TITLE', $newsheadline);
      foreach ($aData as $aValue) {


   $datum = strtotime($aValue["Created"]);
   $tag = date("j",$datum);
   $monat = date("m",$datum);
   $jahr = date("Y",$datum);
   $monat = str_replace(
    array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'),
    array('. Januar ', '. Februar ', '. M&auml;rz ', '. April ', '. Mai ', '. Juni ', '. Juli ', '. August ', '. September ', '. Oktober ', '. November ', '. Dezember '),
   $monat
   );


       $headline_advanced = $aValue["Category"]." - "."$tag$monat$jahr".$aValue["Headline"];
         if ($aSettings["Elements"] > 0) {
            if (!is_object($tpl2)) {     #generate template for elements
            $tpl2 = new Template;
            }
         $tpl2->reset();

            $img_number = 0;
            $text_number = 0;
            for ($i = 0; $i < $aSettings["Elements"]; $i++) {
               switch (TRUE) {
                  case ($aSettings["k".$i]["ElementType"] == "Image" || $aSettings["k".$i]["ElementType"] == "ExtractedImage"):
                  if (!empty($aValue["i".$i]["WebPath"])) {     // modify oldperl: if no Webpath, there's no image
                     $image = $aValue["i".$i]["WebPath"];

                     $width  = $aValue["i".$i]["Width"];
                     $height = $aValue["i".$i]["Height"];

                     if ($aSettings["k".$i]["ElementWidth"] > 0 && $aSettings["k".$i]["ElementHeight"] > 0) {
                        # Check, if resize necessary
                        if ($aValue["i".$i]["ServerPath"] != "" && file_exists($aValue["i".$i]["ServerPath"]) &&
                            ($aValue["i".$i]["Width"] > $aSettings["k".$i]["ElementWidth"] ||
                             $aValue["i".$i]["Height"] > $aSettings["k".$i]["ElementHeight"])) {
                           # Scale image
                           $image = capiImgScale($aValue["i".$i]["ServerPath"], $aSettings["k".$i]["ElementWidth"], $aSettings["k".$i]["ElementHeight"], false, false, 10, false);

                           #Get dimensions of the image
                           list ($width, $height, $type, $attr) = getimagesize($image);
                        } else {
                           $image = $aValue["i".$i]["WebPath"];

                           $width  = $aValue["i".$i]["Width"];
                           $height = $aValue["i".$i]["Height"];
                        }
                     }

                     if ($image != "") {
                        $element_class = 'img_advanced'.$img_number;
                        if ($XHTML == true) {
                        $element_content = '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="" />';                      } else {
                        $element_content = '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="">';
                        }

                        $img_number++;
                     }
                     } else {       // modify oldperl: if no image, we need no template
                        $no_template = true;
                     }
                     break;
                  default: // Everything else is treated as "Text"
                     $element_class = 'text_advanced'.$text_number;  // set the class-value for div
                     $element_content = $aValue["i".$i]["Value"]; // set content for div

                     $text_number++;
               }
                  if(!$no_template) {     // modify oldperl: build tpl only if needed
                   // build elements with template
                   $tpl2->set('d', 'CLASS_ELEMENT', $element_class);
                   $tpl2->set('d', 'CONTENT_ELEMENT',$element_content);
                   $tpl2->next();
                } else {
                   $no_template = false;
                }
            }


            $content_elements = $tpl2->generate('templates/'.$template_advanced2, true);  // save tpl with elements for printing with master-tpl
         }
         if ($XHTML == true) {
         $sign_img = '';
         } else {
         $sign_img = '';
         }
         $show_more = '<a href="'.$aValue["Link"].'">'.mi18n("More...").'</a>';


         $tpl->set('d', 'HEADLINE', $headline_advanced);
         $tpl->set('d', 'COUNT', ($ii % 2));  // Variable füllen für CSS-Class teaser_advanced
         $tpl->set('d', 'CONTENT',  $content_elements);
         $tpl->set('d', 'MORE', $show_more);
         $tpl->set('d', 'SIGN_MORE', $sign_more);


       $tpl->next();
       $ii++; // Variable hochzählen  für CSS-Class teaser_advanced
      }
   }

   # Page browsing
   # Hint: Number of max available records: $lCount
   #       Number of pages: round($lCount / $aSettings["ArticlePerPage"])
   #       First page: nextstep=0
   #       Last page:  nextstep=(round($lCount / $aSettings["ArticlePerPage"]) - 1) * $aSettings["ArticlePerPage"];
   #                   (I have to admit that I'm not sure about the last page formula ... ;-) )
   if ($aSettings["ArticlePerPage"] > 0) {

      # Example: |< 1 ... 3 4 5 ... 8 >|
      $iPages = ceil($lCount / $aSettings["ArticlePerPage"]);
      $sPageBack = '';
      $sPageLinks = '';
      $sPageForward = '';

      $sPageBack = '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep=0">|<</a>';
      for ($i = 1; $i <= $iPages; $i++) {
         $lNextStep = ($i - 1) * $aSettings["ArticlePerPage"];
         if ($i == 1 || $i == $iPages) {
            if ($sPageLinks != '') {
               $sPageLinks .= '&nbsp;';
            }
            if ($_REQUEST["nextstep"] == $lNextStep) {
               $sPageLinks .= $i; # I'm on the current page, no link
            } else {
               $sPageLinks .= '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>';
            }
         } else if ($_REQUEST["nextstep"] == $lNextStep) {
            $sPageLinks .= '&nbsp;'.$i; # I'm on the current page, no link
         } else if ($_REQUEST["nextstep"] == ($lNextStep + $aSettings["ArticlePerPage"])) {
            # Front
            $sPageLinks .= '&nbsp;<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>';
         } else if ($_REQUEST["nextstep"] == ($lNextStep - $aSettings["ArticlePerPage"])) {
            # Back
            $sPageLinks .= '&nbsp;<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.$lNextStep.'">'.$i.'</a>';
         } else if ($_REQUEST["nextstep"] == ($lNextStep - (2 * $aSettings["ArticlePerPage"])) ||
                    $_REQUEST["nextstep"] == ($lNextStep + (2 * $aSettings["ArticlePerPage"]))) {
            $sPageLinks .= '...';
         }
      }

      $sPageForward = '<a href="front_content.php?idcat='.$idcat.'&idart='.$idart.'&nextstep='.(ceil($lCount / $aSettings["ArticlePerPage"]) - 1) * $aSettings["ArticlePerPage"].'">>|</a>'."\n";

   }
   $tpl->set('s', 'BACK', $sPageBack);
   $tpl->set('s', 'PAGESELECTOR', $sPageLinks);
   $tpl->set('s', 'FORWARD', $sPageForward);

   $tpl->generate('templates/'.$template_advanced);
}
# Clearing memory
unset ($aData);
unset ($aSettings);
unset ($i);
unset ($lCount);
unset ($bDebug);
?> 
Niteflight
Beiträge: 3
Registriert: Sa 18. Nov 2006, 16:37
Kontaktdaten:

Hallo

Beitrag von Niteflight »

Ich habe ein echtes Problem mit dem Modul.
Mein Ziel: Ich möchte gerne eine zufällige Ausgabe eines Artikels auf der Startseite der Webseite. Der Artikel soll aus einem Bild und ein wenig Text bestehen. Die Ausgabe soll nicht verlinkt werden oder was auch immer. Einfach nur einen Artikel random auswählen und ausgeben - fertig.

Ich bin nun absoluter Contenido-Neuling und habe heute schon den ganzen Tag gemacht undgetan und probiert, das Modul zum laufen zu bekommen aber es geht nicht.

So weit bin ich:
Der Input-Helper habe ich nach cms/includes kopiert

die beiden anderen Dateien habe ich wie beschrieben hochgeladen.

Ich habe mir ein simples Layout angelegt mit nur einem container

diesen container verbdinde ich im Template mit dem Advanced-Modul und wähle als Primäre Kategorie meinen Ordner "Systemordner/MAs" aus.

Aber da kann ich schon des "Headline-Element" nicht auswählen. Es ist grau hinterlegt und nicht anzuklicken. Wieso nicht? Des kapier ich schonmal nicht.

So, dann habe ich im Systemordner/MAs 2 Artikel angelegt. Und beide sind auch online. Wenn ich nun die Artilkel mittm Editor bearbeiten will erscheint nur eine weisse Seite und kein Editor. Das versteh ich na klar auch nicht.

Ist sicher nur eine Kleinigkeit, die ich übersehen bzw nicht verstanden habe. Kann mir jemand weiter helfen?

Vielen Dank in advance.
Matthias
Gesperrt