Seite 1 von 1

Artikel-Blättern aus 4.4.x anpassen für 4.6.x

Verfasst: Mi 29. Mär 2006, 20:00
von cassiopeia
Hallo zusammen!

Das Artikel-Bättern-Modul von forseth.de verwende ich schon einige Zeit in einer 4.4.5 Installation - es funktioniert äußerst zuverlässig. Mir gefällt es so gut, weil es einfach und schlicht ist:
Rechts und links die Links zum Blättern (zurück und vor), in der Mitte wird ausgegeben "zurück zur Übersicht" und "Artikel x von y". Außerdem zeigt es das Erstellungsdatum des Artikels mit an.

Meine Frage: was muss ggfs. geändert werden, damit es auch unter 4.6.4 zuverlässig den Startartikel ausschließt - ich hab da keinen Schimmer - SORRY :oops: und hoffe, es ist nicht zu kompliziert. Bei einem Test mit dem Beispielmandanten springt es zwischendurch auf den Startartikel (Liste) statt vor oder zurück. Hier der Einfachheit halber gleich der Code (es gibt nur den Output), da ich ihn hier im Forum nicht finde - und danke schon mal für die Hilfe. Auch danke für das tolle Forum, dass mir schon so oft ungefragt weitergeholfen hat, dass dies erst mein 2. Posting ist :wink:

Code: Alles auswählen

<?php

##################################
# OUTPUT - Newsartikelblaettern  #
#                                #
# Author: Lars D. Forseth        #
#         <lars@forseth.de>      #
# Created: Feb. 5th 2004         #
#                                #
##################################



// get articles from DB
$sql = "SELECT ARTLANG.idart, ARTLANG.title, CATART.idcat, ARTLANG.created, CONTENT.value, ".
       "CONTENT.idtype, CONTENT.typeid FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".
       $cfg["tab"]["art_lang"]." AS ARTLANG, ".$cfg["tab"]["cat"]." AS CAT, ".
       $cfg["tab"]["content"]." AS CONTENT WHERE ARTLANG.idart = CATART.idart ".
       "AND CATART.idcat = CAT.idcat AND ARTLANG.idartlang=CONTENT.idartlang ".
       "AND CONTENT.idtype<=2 AND CONTENT.typeid<=2 AND CAT.idcat='$idcat' AND ARTLANG.idlang = '$lang' ".
       "AND ARTLANG.online = '1' AND CATART.is_start='0' ORDER BY ARTLANG.artsort ASC,ARTLANG.created ".
       "DESC";
$db->query($sql);



/* there are articles */
if ($db->num_rows() != 0) {


  $db->next_record();                           // get first row
  $links        = explode('?',$PHP_SELF);
  $link         = $links[0];                    // plain link
  $rows         = $db->num_rows();              // initialize number of articles
  $last         = $db->f("idart");              // id of last article
  $first        = $db->f("idart");              // initialize var for first article id
  $articles     = array();                      // array for the ids of the articles
  $created      = " ";                          // initialize "created"


  for ($i = 0; $i < $rows; $i++) {

    // only add the id of not already added articles
    if (!in_array(($db->f("idart")), $articles)) {$articles[$i] = $db->f("idart");}

    // if fetched article is the current shown get "created"
    if(($db->f("idart")) == $idart) {
      $created = substr($db->f("created"),8,2).".".substr($db->f("created"),5,2).".".substr($db->f("created"),0,4);
    } // end if

    $first = $db->f("idart");
    $db->next_record();

  } // end for


  $articles = array_values($articles);          // resort articles in correct form ([0],[1],[2],...)
  $rows = count($articles);                     // number of articles
  $key = array_search($idart, $articles);       // position of current idart in articles-array


  // check for prev-link
  if (($key+1) < $rows) {
    $prev = $link."?lang=".$lang."&client=".$client."&idcat=".$idcat."&idart=".$articles[($key+1)];
  } else {$prev = " ";}


  // check for next-link
  if (($key-1) >= 0) {
    $next = $link."?lang=".$lang."&client=".$client."&idcat=".$idcat."&idart=".$articles[($key-1)];
  } else {$next = " ";}


  // print next- and prev-link, if necessary
  echo "

  <!-- start Artikelblättern -->
  <br><br><div align=\"right\" class=\"text\"><b>Erstellt am ".$created." .</b></div>
  <br><br><br><br><br><br><br>
  <table border =\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"text\">
   <tr valign=\"top\">
    <td align=\"left\" width=\"45\">";
  if($next != " ") {echo "<a href=\"".$next."\">&nbsp;&laquo;&nbsp;next&nbsp;</a>";}
  else {echo $next;}
  echo "</td>
    <td align=\"center\">&ndash;&nbsp;&nbsp;Artikel ".($key+1)." / ".$rows."&nbsp;&nbsp;&ndash;</td>
    <td align=\"right\" width=\"45\">";
  if ($prev != " ") {echo "<a href=\"".$prev."\">&nbsp;prev &raquo;&nbsp;</a>";}
  else {echo $prev;}
  echo "</td>
   </tr>
   <tr valign=\"bottom\">
    <td colspan=\"3\" align=\"center\">
     <a href=\"".$link."?idcat=".$idcat."\">&laquo;&nbsp;Zur&uuml;ck zur&nbsp;&Uuml;bersicht&nbsp;&raquo;</a>
    </td>
   </tr>
   <tr><td colspan=\"3\">&nbsp;</td></tr>
   <tr><td colspan=\"3\">&nbsp;</td></tr>
  </table>
  <!-- end Artikelblättern -->

  ";


} // end "there are articles"



/* there are no articles */
else {
echo "Momentan sind keine Artikel vorhanden...";
} // end else



?>


Gruß CP

Verfasst: Fr 31. Mär 2006, 16:20
von emergence
so auf den ersten blick kann es sein das

Code: Alles auswählen

 AND CATART.is_start='0'
nicht so ganz funktionieren könnte...

ausser man setzt in der

includes/config.php

Code: Alles auswählen

/* Start article compatibility mode */
$cfg["is_start_compatible"] = true;

Verfasst: Mo 3. Apr 2006, 21:31
von cassiopeia
Vielen Dank emergence -
so ungefähr hab ich das bereits vermutet! Ich habe allerdings keinen Schimmer, ob bzw. wie es möglich ist, diese Startartikelgeschichte für 4.6 anzupassen. Es handelt sich wie gesagt um eine Neuinstallation und ich möchte daher die config.php so lassen wie sie ist.

Werde alternativ dann wohl doch auf das Blättermodul mit den Seitenzahlen zurückgreifen ... Schade eigentlich - ist ein schickes Modul!

Gruß CP