Suche Bilder lösung für Projekt

baumpaul
Beiträge: 346
Registriert: Mo 1. Mär 2004, 12:59
Kontaktdaten:

Beitrag von baumpaul » Do 11. Nov 2004, 16:19

Ja das habe ich gefunden aber nach den kleinen Bildern ist immer noch Raum. Das muss an etwas anderem leigen.

Code: Alles auswählen

      $returnvalue = "<div><img src=\"{$this->bild[0][0]}\" name=\"picOnClickTarget\" /><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"20\"></td></tr></table></div>";

      $counter = 1;
      for ($j=1;$j<3;$j++) {

         $returnvalue .= "<div>";
         for ($k=1;$k<6;$k++) {
            
            $returnvalue .= $this->getImageCode($counter++);
            $returnvalue .= "&nbsp;\n";
         }
         $returnvalue .= "</div>";

      }

      return $returnvalue;
   }

   function getImageCode($i) {

      
      $index = $i*2;

      if (empty($this->bild[$index-1][0])) return '';
      
      $returnvalue = "<a href=\"javascript:picOnClick(picOnClickTarget,Bild$index)\"><img src=\"{$this->bild[$index-1][0]}\" border=\"0\" onClick=\"picOnClick(picOnClickTarget,Bild$index)\" /></a>";

      return $returnvalue;
   }
}

$picOnClick = new picOnClick();
?>
Ich finde nichts was in den Code noch einen Umbruch verursachen könnte.

kummer
Beiträge: 2423
Registriert: Do 6. Mai 2004, 09:17
Wohnort: Bern, Schweiz
Kontaktdaten:

Beitrag von kummer » Do 11. Nov 2004, 16:40

sorry, mein fehler. das script macht zwei zeilen mit je fünf bildern. das willst du ja nicht, weil du nur fünf bilder hast, oder?

du musst folglich die for-schlaufe weglassen, die zweimal durchlaufen wird. also anstatt:

Code: Alles auswählen

for ($j=1;$j<3;$j++) { 

         $returnvalue .= "<div>"; 
         for ($k=1;$k<6;$k++) { 
            
            $returnvalue .= $this->getImageCode($counter++); 
            $returnvalue .= "&nbsp;\n"; 
         } 
         $returnvalue .= "</div>"; 

      } 
nur noch:

Code: Alles auswählen

$returnvalue .= "<div>"; 
         for ($k=1;$k<6;$k++) { 
            
            $returnvalue .= $this->getImageCode($counter++); 
            $returnvalue .= "&nbsp;\n"; 
         } 
         $returnvalue .= "</div>";
gruss,
andreas
aitsu.org :: schnell - flexibel - komfortabel :: Version 2.2.0 (since June 22, 2011) (jetzt mit dual license GPL/kommerziell)

baumpaul
Beiträge: 346
Registriert: Mo 1. Mär 2004, 12:59
Kontaktdaten:

Beitrag von baumpaul » Do 11. Nov 2004, 16:51

Ahja, sowas habe ich mir schon gedacht.

Ich habe bis 6 Bilder aber am besten ist es, wenn die Bilder einfach durch ein Leerzeichen getrennt sind und falls noch eines kommt, das einfach in die nächste Zeile rutscht.
Wollte in der überarbeiteten Version aber 7 in eine Reihe bringen und bis 12 anbieten.

So, mal schaun, jetzt werde ich es schon hin bekommen.

Thx noch ein mal.

baumpaul
Beiträge: 346
Registriert: Mo 1. Mär 2004, 12:59
Kontaktdaten:

Beitrag von baumpaul » Mi 17. Nov 2004, 08:34

Hallo,

ich habe dein Script bei mir jetzt eingebaut, aber bei mir werden nicht mehr als 5 Bilder angezeigt es sollten aber bis zu 14 Stück sein, die nur durch ein leerzeichen getrennt sind.

Was ist darin falsch?

Code: Alles auswählen

<?php

class picOnClick {

   function picOnClick() {

      global $edit;

      $this->setIniValues();
      
      if ($edit) {
         $this->showEditPics();
      } else {
         echo $this->getJsCode();
         echo $this->getPics();
      }
   }

   function setIniValues() {
      
      $this->bild[0] =array("CMS_IMG[100]","CMS_IMGDESCR[100]","CMS_LINKDESCR[100]");
      $this->bild[1] =array("CMS_IMG[101]","CMS_IMGDESCR[101]","CMS_LINKDESCR[101]");
      $this->bild[2] =array("CMS_IMG[102]","CMS_IMGDESCR[102]","CMS_LINKDESCR[102]");
      $this->bild[3] =array("CMS_IMG[103]","CMS_IMGDESCR[103]","CMS_LINKDESCR[103]");
      $this->bild[4] =array("CMS_IMG[104]","CMS_IMGDESCR[104]","CMS_LINKDESCR[104]");
      $this->bild[5] =array("CMS_IMG[105]","CMS_IMGDESCR[105]","CMS_LINKDESCR[105]");
      $this->bild[6] =array("CMS_IMG[106]","CMS_IMGDESCR[106]","CMS_LINKDESCR[106]");
      $this->bild[7] =array("CMS_IMG[107]","CMS_IMGDESCR[107]","CMS_LINKDESCR[107]");
      $this->bild[8] =array("CMS_IMG[108]","CMS_IMGDESCR[108]","CMS_LINKDESCR[108]");
      $this->bild[9] =array("CMS_IMG[109]","CMS_IMGDESCR[109]","CMS_LINKDESCR[109]");
      $this->bild[10] =array("CMS_IMG[110]","CMS_IMGDESCR[110]","CMS_LINKDESCR[110]");
      $this->bild[11] =array("CMS_IMG[111]","CMS_IMGDESCR[111]","CMS_LINKDESCR[111]");
      $this->bild[12] =array("CMS_IMG[112]","CMS_IMGDESCR[112]","CMS_LINKDESCR[112]");
      $this->bild[13] =array("CMS_IMG[113]","CMS_IMGDESCR[113]","CMS_LINKDESCR[113]");
      $this->bild[14] =array("CMS_IMG[114]","CMS_IMGDESCR[114]","CMS_LINKDESCR[114]");
      $this->bild[15] =array("CMS_IMG[115]","CMS_IMGDESCR[115]","CMS_LINKDESCR[115]");
      $this->bild[16] =array("CMS_IMG[116]","CMS_IMGDESCR[116]","CMS_LINKDESCR[116]");
      $this->bild[17] =array("CMS_IMG[117]","CMS_IMGDESCR[117]","CMS_LINKDESCR[117]");
      $this->bild[18] =array("CMS_IMG[118]","CMS_IMGDESCR[118]","CMS_LINKDESCR[118]");
      $this->bild[19] =array("CMS_IMG[119]","CMS_IMGDESCR[119]","CMS_LINKDESCR[119]");
      $this->bild[20] =array("CMS_IMG[120]","CMS_IMGDESCR[120]","CMS_LINKDESCR[120]");
      $this->bild[21] =array("CMS_IMG[121]","CMS_IMGDESCR[121]","CMS_LINKDESCR[121]");
      $this->bild[22] =array("CMS_IMG[122]","CMS_IMGDESCR[122]","CMS_LINKDESCR[122]");
      $this->bild[23] =array("CMS_IMG[123]","CMS_IMGDESCR[123]","CMS_LINKDESCR[123]");
      $this->bild[24] =array("CMS_IMG[124]","CMS_IMGDESCR[124]","CMS_LINKDESCR[124]");
      $this->bild[25] =array("CMS_IMG[125]","CMS_IMGDESCR[125]","CMS_LINKDESCR[125]");
      $this->bild[26] =array("CMS_IMG[126]","CMS_IMGDESCR[126]","CMS_LINKDESCR[126]");
      $this->bild[27] =array("CMS_IMG[127]","CMS_IMGDESCR[127]","CMS_LINKDESCR[127]");
      $this->bild[28] =array("CMS_IMG[128]","CMS_IMGDESCR[128]","CMS_LINKDESCR[128]");
   }

   function showEditPics() {

      foreach ($this->bild as $key => $bild) {
      
         echo '<p>';

         $key2 = floor($key / 2);
         $key3 = $key / 2;
         $gerade = ($key3 == $key2)?(true):(false);
   
         if ($key == 0) {
            echo '<div><strong>Grosses Bild (Anfangszustand):</strong></div>';
         } elseif ($gerade) {
            $bildnr = $key/2;
            echo "<div>Bild Nr. $bildnr (gross)</div>";
         } else {
            $bildnr = floor($key/2) + 1;
            echo "<div>Bild Nr. $bildnr (klein)</div>";
         }
         
         if ($bild[0] != "") echo "<div><img src=\"{$bild[0]}\" border=\"0\"></div>";
         echo "{$bild[1]}";
         echo "{$bild[2]}";

         echo '</p>';
      }
   }

   function getJsCode() {

      $returnvalue = "
         <script type=\"text/javascript\">
         <!--
         ";

      for ($i=2;$i<count($this->bild);$i=$i+2) {

         $returnvalue .= $this->getJsCodeSnippet($i);
      }

      $returnvalue .= "
         function picOnClick(Bildnr,Bildobjekt) {
            Bildnr.src = Bildobjekt.src;
         }
         //-->
         </script>
         ";

      return $returnvalue;
   }

   function getJsCodeSnippet($i) {

      if (empty($this->bild[$i][0])) return '';
   
      $returnvalue = "
         Bild$i = new Image();
         Bild$i.src = \"{$this->bild[$i][0]}\";
         ";

      return $returnvalue;
   }

   function getPics() {

      $returnvalue = "<div><img src=\"{$this->bild[0][0]}\" name=\"picOnClickTarget\" /><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"20\"></td></tr></table></div>";
//      echo "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"20\"></td></tr></table>";

      $counter = 1;

      $returnvalue .= "<div>";
         for ($k=1;$k<6;$k++) {
           
            $returnvalue .= $this->getImageCode($counter++);
            $returnvalue .= "&nbsp;\n";
         }
         $returnvalue .= "</div>";

      return $returnvalue;
   }

   function getImageCode($i) {

      
      $index = $i*2;

      if (empty($this->bild[$index-1][0])) return '';
      
      $returnvalue = "<a href=\"javascript:picOnClick(picOnClickTarget,Bild$index)\"><img src=\"{$this->bild[$index-1][0]}\" border=\"0\" onClick=\"picOnClick(picOnClickTarget,Bild$index)\" /></a>";

      return $returnvalue;
   }
}

$picOnClick = new picOnClick();
?>

kummer
Beiträge: 2423
Registriert: Do 6. Mai 2004, 09:17
Wohnort: Bern, Schweiz
Kontaktdaten:

Beitrag von kummer » Mi 17. Nov 2004, 10:16

diese schlaufe zählt nur von 1 bis 5:

Code: Alles auswählen

for ($k=1;$k<6;$k++) { 
            
            $returnvalue .= $this->getImageCode($counter++); 
            $returnvalue .= "&nbsp;\n"; 
         } 
erhöhe einfach den wert auf den gewünschten wert (also z.b. 20).
aitsu.org :: schnell - flexibel - komfortabel :: Version 2.2.0 (since June 22, 2011) (jetzt mit dual license GPL/kommerziell)

Gesperrt