Artikelliste

Gesperrt
Rotschopf
Beiträge: 40
Registriert: So 10. Jul 2005, 22:17
Kontaktdaten:

Artikelliste

Beitrag von Rotschopf » Do 6. Okt 2005, 22:37

Hallöchen,

ich habe mal ein kleines Problem und hoffe einer hat die Zeit mir das zu lösen.
Und zwar habe ich die Standard Artikelliste so abgeändert, das die Artikeltexte ausgegeben werden

Output

Code: Alles auswählen

// second db class instance 
$db2 = new DB_Contenido; 

// selected category 
$selcat = "CMS_VALUE[0]"; 

 if($selcat!="0" && $selcat!=""){ 

// select all articles in category widthout start article 
$query = "SELECT ARTLANG.idart, ARTLANG.idartlang FROM ".$cfg["tab"]["cat_art"]." AS CATART, ". 
          $cfg["tab"]["art_lang"]." AS ARTLANG ". 
         "WHERE CATART.idcat = '$selcat' AND ARTLANG.idart = CATART.idart AND ARTLANG.idlang = '$lang' AND ". 
         "ARTLANG.online = '1' ORDER BY CATART.idart DESC"; 

// execute query 
$db->query($query); 

unset($articleID); 
unset($linkID); 

// get id's of sub articles 
while ($db->next_record()) { 
  if (!isStartArticle($db->f("idartlang"), $selcat, $lang)) 
  { 
      $articleID[] = $db->f("idartlang"); 
      $linkID[] = $db->f("idart"); 
  } 
} // end while 

// loop through subarticles 

echo ' 
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FCF2D5"> 
'; 

if (is_array($articleID)) { 

    foreach ($articleID as $key => $value) { 

          // select all CMS variables of the article 
          $sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '2' AND typeid = '1'"; 
          $db->query($sql); 
          $db->next_record(); 
          $head = $db->f("value"); 

          if ( strlen($head) > "CMS_VALUE[3]") { 
            $head = substr($head, 0, "CMS_VALUE[3]"); 
            $head .= '..'; 
          } 

          // link 
          $link = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$selcat&idart=$linkID[$key]&m=$m&s=$s"); 

          echo '<tr><td colspan="2" class="text" height="22" style="background-color: #FCF2D5"><a href="'.$link.'">'.urldecode($db->f("value")).'</a></td></tr>'; 

    } // end while 



          unset($headline); 
        unset($text); 
        
    } // end foreach 
    
} // end if (is_array) 

echo '</table><br>'; 


?> 

das klappt auch ohne Probleme!
Was ich von dir gerne hätte, wäre die Funktion, das maximal 20 Artikel pro 'seite' angezeigt werden und ich blättern kann. Also oben und unten je zwei Button mit weiter und zurück.
Eigentlich müsste das doch zu realisieren sein oder?

Ach das wichtigste hätte ich ja fast vergessen, diese Sache ist mir auch eine kleinigkeit wert.
Gruß
Arne (Rotschopf)

emergence
Beiträge: 10641
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence » Sa 8. Okt 2005, 07:00

also wenn du die 4.5.3 einsetzt (was ich jetzt nicht weiss, da du es nicht geschrieben hast), würde ich an deiner stelle die
class.article.php benützen... (doku ist im file selbst vorhanden)
eine blätter funktion läßt sich damit relativ einfach realisieren, da die klasse es zur verfügung stellt... mit etwas herumprobieren solltest du dein problem in 15-30 minuten selbst lösen können...
*** make your own tools (wishlist :: thx)

Rotschopf
Beiträge: 40
Registriert: So 10. Jul 2005, 22:17
Kontaktdaten:

Artikelliste mit Text und blättern

Beitrag von Rotschopf » Di 18. Okt 2005, 23:20

Vielen Dank an emergence, der die Liste das Modul für mich gebaut hat.
Ich hab das nun getestet (mit Contenido 4.5.3), ein wenig angepasst und es läuft 1a!!!
Natürlich will ich es niemandem vor enthalten, also anbei der code:

Code: Alles auswählen

/** 
* Artikelliste mit Blätterfunktion 
* 
* Erstellt eine Liste mit allen Artikel bis 
* auf den Startartikel. 
* 
* INPUT 
* 
* Author Jan Lengowski, Martin Horwath 
* Copyright four for business AG 
*/ 

// selected category 
$selected = "CMS_VALUE[0]"; 

echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\"> 
        <tr valign=\"top\"> 
          <td>Kategorie wählen:</td> 
          <td> 
            <select name=\"CMS_VAR[0]\">"; 
            if($selected!="0" && $selected!=""){ 
             echo"<option value=\"0\">--- kein ---</option>"; 

            }else{ 
            echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>"; 
            } 

            // fetch all categorys 
            $query = "SELECT A.idcat, A.level, C.name FROM ".$cfg["tab"]["cat_tree"]." AS A, ". 
                     $cfg["tab"]["cat"]." AS B,  ".$cfg["tab"]["cat_lang"]." AS C WHERE A.idcat=B.idcat ". 
                     "AND B.idcat=C.idcat AND C.idlang='$lang' AND B.idclient='$client' ". 
                     "AND C.visible=1 ORDER BY A.idtree"; 
            // execute query 
            $db->query($query); 

            // loop result and build the options 
            while ($db->next_record()) { 

              // indent spacer 
              $spaces = "|"; 

              // how many levels 
              $levels = $db->f("level"); 

              for ($i = 0; $i < $levels; $i ++) { 
                // add 2 spaces for every level 
                $spaces = $spaces . "--"; 

              } // end for 
              
              $spaces .= ">"; 


              if ($selected == $db->f("idcat")) { 
                // selected category 
                echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>"; 

              } else { 
                // category 
                echo "<option value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>"; 

              } // end if 

            } // end while 

echo "      </select>"; 

echo "    </td> 
        </tr> 
        <tr> 
          <td>Überschrift</td> 
          <td><input type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\"></td> 
        </tr> 
        <tr> 
          <td>Angezeigte Länge in Zeichen</td> 
          <td><input type=\"text\" name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\"></td> 
        </tr> 
        <tr> 
          <td>Anzahl der Artikel pro Seite</td> 
          <td><input type=\"text\" name=\"CMS_VAR[4]\" value=\"CMS_VALUE[4]\"></td> 
        </tr> 
      </table>";

Code: Alles auswählen

<?php 

// selected category 
$selcat = "CMS_VALUE[0]"; 
$articleperpage = "CMS_VALUE[4]"; 

// smaller values than 1 should not be possible 
if ($articleperpage < 1) $articleperpage = 10; 

if ($selcat != "0" && $selcat != "") { 

   // select all articles in category widthout start article 
   $sql = "SELECT ARTLANG.idart, ARTLANG.idartlang FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".$cfg["tab"]["art_lang"]." AS ARTLANG "."WHERE CATART.idcat = '$selcat' AND ARTLANG.idart = CATART.idart AND ARTLANG.idlang = '$lang' AND "."ARTLANG.online = '1' ORDER BY CATART.idart DESC"; 

   // execute query 
   $db->query($sql); 

   unset ($articleID); 
   unset ($linkID); 

   // get id's of sub articles 
   while ($db->next_record()) { 
      if (!isStartArticle($db->f("idartlang"), $selcat, $lang)) { 
         $articleID[] = $db->f("idartlang"); 
         $linkID[] = $db->f("idart"); 
      } 
   } // end while 

   // we start at first page 
   if (!isset($page)) { 
      $page = 1; // this variable will not be cleaned up 
   } 

   $next = false; 
   $previous = false; 

   if (is_array($articleID)) { 
      $count = count ($articleID); // this variable will not be cleaned up 

      // decide how many pages are possible 
      $tmppages = ceil($count / $articleperpage); 
            
      // more pages are possible 
      if ($tmppages > 1) { 
        
         $tmpstart = ($page-1) * $articleperpage; 
         $tmpend = $page * $articleperpage; 
            
         // remove unwanted articles 
         $articleID = array_slice ($articleID, $tmpstart, $tmpend); 
         $linkID = array_slice ($linkID, $tmpstart, $tmpend); 
            
         if ($page > 1) { 
            $previous = $page - 1; 
         } 
            
         if ($tmpend < $count) { 
            $next = $page + 1; 
         } 
            
         if ($next) $next = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&page=$next"); 
         if ($previous) $previous = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&page=$previous"); 
            
         // cleanup unused variables 
         unset ($tmpstart, $tmpend, $tmppages); 
      } 

   } 


   // loop through subarticles 
   if (is_array($articleID)) { 

      echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FCF2D5"><tr>'; 
      // show previous page link 
      if ($previous) echo '<td><a href="'.$previous.'"><font size="5" color="#000099"><strong>Zurück</a></strong></font></td>'; 
      // show next page link 
      if ($next) echo '<td align="right"><a href="'.$next.'"><font size="5" color="#000099"><strong>Weitere</a></strong></font></td>'; 
      echo '</tr> </table>';
      
      echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FCF2D5">'; 

      foreach ($articleID as $key => $value) { 

         // select all CMS variables of the article 
         $sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '2' AND typeid = '1'"; 
         $db->query($sql); 
         $db->next_record(); 
         $head = $db->f("value"); 

         if (strlen($head) > "CMS_VALUE[3]") { 
            $head = substr($head, 0, "CMS_VALUE[3]"); 
            $head .= '..'; 
         } 

         // link 
         $link = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$selcat&idart=$linkID[$key]"); 

         echo '<tr><td colspan="2" class="text" height="22" style="background-color: #FCF2D5"><a href="'.$link.'">'.urldecode($db->f("value")).'</a></td></tr>'; 

      } // end foreach 

      echo '</table><br>'; 

      echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FCF2D5"><tr>'; 
      // show previous page link 
      if ($previous) echo '<td><a href="'.$previous.'"><font size="5" color="#000099"><strong>Zurück</a></strong></font></td>'; 
      // show next page link 
      if ($next) echo '<td align="right"><a href="'.$next.'"><font size="5" color="#000099"><strong>Weitere</a></strong></font></td>'; 
      echo '</tr> </table>';

      // cleanup unused variables 
      unset ($head, $link, $articleID, $linkID, $value, $key); 

   } // end if (is_array) 

   // cleanup unused variables 
   unset ($previous, $next); 

} // end if ($selcat) 

// cleanup unused variables 
unset ($selcat, $articleperpage); 

?>
Viel Spass damit

jost
Beiträge: 322
Registriert: Mo 10. Jan 2005, 20:12
Kontaktdaten:

Beitrag von jost » Di 18. Okt 2005, 23:35

Ähm, besten Dank 8)

Gesperrt