• Welcome to WebsiteBaker Community Forum. Please log in or sign up.
Welcome, Guest
News
Support WebsiteBaker
Your donations will help to:
PayPal
  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!
You can donate by clicking on the button below.

PHP help!!!!

Started by Peeters, December 02, 2009, 06:27:36 PM  ( Read 19,056 times )

Peeters

Hi,
On my website, I've a list of all products we sell (2000+). For each producer I would like to show their logo in a pop-up. Is there a way by which I can use one file (logo.php) for all logo's (like logo.php?id=Trimbach_Wines and logo.php?id=Trimbach_Wines)
Hope you guys can help me out :P
Thanks,
Duco

    Waldschwein

    Hello,

    hmm hmm... I know that problem very good here on that sites: http://www.deutschemaler.de/seiten/vorhandene-kuenstler/burghart-toni.php
    It was quite a mess to create a site for each picture, get the thumbnail manually and create a link from the thumbnail to picture... But I had no real other choice, because they wanted it exactly like that (and well, google likes it, too).
    In the end there has to be a module and a kind of pattern you can define.
    But I haven't found anything that would help out here.

    Yours Michael

      Peeters

      Thanks anyway, but I think it's a bit too much for 2000+ producers :P

      Anyone else ???? PLEASE !!!

        pcwacht

        You need something like this?
        http://www.henc.nl/pages/cpu-moederborden.php

        There is a litle php script runnin gin a code section, it fetches a text file and shows (in this case) only motherboards. IN the textfile is the name of the article wich is used for the small image, you can click on the small image and a popup comes with a larger image, if it exists, or a larger image of the same image

        This scripts uses a text file, but can be a mysql tabel as well


        <?php
        $pad
        = WB_PATH.'/media/somepath/';
        $pad2 = WB_URL.'/media/somepath/';
        $artikelen = $pad.'sometextfile.txt';
        $handle = fopen ($artikelen, "r");
        $vars = array('[NAAM]','[TEKST]','[PRIJS]');
        $loopstart = '<table cellspacing="0" cellpadding="1" width="100%" border="1">
        <tr><th><b>Artikel</b></th><th><b>Omschrijving</b></th><th><b>Stuksprijs</b></th></tr>
        '
        ;
        $loop1 = '<tr><td valign="top">[NAAM]</td><td valign="top">[TEKST]</td><td valign="top" align="right">[PRIJS]</td></tr>';
        $loopend = '</table><br />';

        if (
        $handle )   {
           echo
        "Moederborden<br />";
           echo
        $loopstart;
           while (!
        feof ($handle)) {
             
        $buffer = fgets($handle, 4096);
               
        $art0=trim(substr($buffer,0,12));
               
        $art1=trim(substr($buffer,12,33));
               
        $art2=trim(substr($buffer,46,8));
               
        $art3=trim(substr($buffer,64,3));
              switch (
        $art3) {
                case
        "MAI":
                 
        $file1=$pad.$art0.'.jpg';
                 
        $file12=$pad2.$art0.'.jpg';
                 
        $file4=$pad.$art0.'-2.jpg';
                 
        $file42=$pad2.$art0.'-2.jpg';
                 
        $file2=$pad.$art0.'.txt';

                  if (
        file_exists($file4)) {
                     
        $size = getimagesize("$file4");
                     
        $height = $size[1]+20;
                     
        $width = $size[0]+20;
                     
        $art0='<a href="javascript:popUp('.$width.','.$height.',';
                     
        $art0.= "'$file42'";
                     
        $art0.= ')" ><img src="'.$file12.'" width=80 heigth=60 border=0 alt="'.$art0.'"></a>';
                  } elseif (
        file_exists($file1)) {
                     
        $size = getimagesize("$file1");
                     
        $height = $size[1]+20;
                     
        $width = $size[0]+20;
                     
        $art0='<a href="javascript:popUp('.$width.','.$height.',';
                     
        $art0.= "'$file12'";
                     
        $art0.= ')" ><img src="'.$file12.'" width=80 heigth=60 border=0 alt="'.$art0.'"></a>';
                  }

                   if (
        file_exists($file2)) {
                     
        $art1=file_get_contents ($file2);
                  }
                   
        $values=array($art0,$art1,$art2);
                   echo
        str_replace($vars,$values,$loop1);
                   break;

                default:
                   break;
              }


           }
           echo
        $loopend;
           
        fclose($handle);
        } else {
          die(
        "Bestand : $filename niet gevonden" ) ;
        }
        ?>


        Have fun,
        John
          http://www.ictwacht.nl = Dutch ICT info
          http://www.pcwacht.nl = My first
          both still work in progress, since years.....

          Peeters

          I'm gonna try it tomorrow / Ga ik morgen uitproberen

            pcwacht

            http://www.ictwacht.nl = Dutch ICT info
            http://www.pcwacht.nl = My first
            both still work in progress, since years.....

            Peeters

            Yeah, but they stopped working :( now i'm seeing [[LastModified]] instead of 'laatste verandering: 30-11-2009 om 11:12'

              Peeters

              Quote from: pcwacht on December 02, 2009, 10:05:44 PM
              You need something like this?
              http://www.henc.nl/pages/cpu-moederborden.php

              There is a litle php script runnin gin a code section, it fetches a text file and shows (in this case) only motherboards. IN the textfile is the name of the article wich is used for the small image, you can click on the small image and a popup comes with a larger image, if it exists, or a larger image of the same image

              This scripts uses a text file, but can be a mysql tabel as well

              code

              Have fun,
              John

              what file did you use as 'sometextfile.txt'??? 'cause mine didn't work  :x

                pcwacht

                a textfile with fixed length fields

                You can see the 'parts'
                $art0=trim(substr($buffer,0,12));
                       
                $art1=trim(substr($buffer,12,33));
                       
                $art2=trim(substr($buffer,46,8));
                       
                $art3=trim(substr($buffer,64,3));

                where
                - art0 = article code, wich is allso the article picture
                - art1 = description
                - art2 = price
                - art3 = productgroup, when 'mai' it is a motherboard (mainboard)


                John
                  http://www.ictwacht.nl = Dutch ICT info
                  http://www.pcwacht.nl = My first
                  both still work in progress, since years.....

                  Peeters

                  #9
                  No, that's not what I meant (sorry  :-) ) What I meant:
                  I have a list of products we sell I want to be able to show our customers a logo (when they click on the name of a producer), but, since we have 2000+ products I don't want to create a seperate page for each logo, 'cause it will take too much time. Is there a way by which I can create a file, like 'logo.php' which redirects 'logo.php?id=6' to their logo (another way is also fine with me :P)

                  thanks,
                  duco

                    mr-fan

                    hi,
                    is a kind of lightbox for the logo's a poissibility?

                    you want such logos like on this site http://www.wijnhandel-peeters.com/peeters/nederlands/assortiment/champagne.php

                    for all producers? right...you've these logos right?

                    so i think you must "link" this producers with the logos in every way.... :roll:

                    so you can use a lightbox script set a link on every producer to the picture and ready - or use the .txt file from pcwacht to reorder the whole content together with pics

                    regards martin

                      pcwacht

                      #11
                      hmmm,
                      I am thinking of a droplet wich creates the link (javascript like the code for henc.nl)

                      Something like:
                      scan for producer name -> change producer name wicth appropriete javascript code
                      so in a droplet:

                      // Need some wb variables, make them available
                      global $wb;    

                      // $wb_page_data holds the output of the current page
                      // Search for producername and replace it
                      $producer_name[1] = 'name_of_producer1';
                      $producer_picture[1] = 'picture_of_producer1.jpg';
                      $producer_name[2] = 'name_of_producer2';
                      $producer_picture[2] = 'picture_of_producer2.jpg';

                      // Here the code starts:
                      $arr_size=count($producer_name);
                      for(
                      $i=1;$i<$arr_size;$i++) {
                         
                      $js_picture ='<a href="javascript:popUp('.$width.','.$height.',';
                         
                      $js_picture .= WB_URL."/media/producers/'$producer_picture[$i]'";
                         
                      $js_picture .= ')" ><img src="'.WB_URL."/media/producers/'$producer_picture[$i]'".'" width=80 heigth=60 border=0 alt="'.$producer_name[$i].'"></a>';
                         
                      $wb_page_data = str_replace("producer_name[$i]", $js_picture, $wb_page_data);
                      }
                      // Since the output was directly altered we don't have something to return
                      // But we must return at least TRUE!
                      return TRUE;


                      Mind you, I didn't tested the code so don't know if I made a typo somewhere, but I am sure it will give you enough to get you started.

                      Allso the useage of droplets to manipulate the page output is once again good demonstrated.

                      Have fun,
                      John
                        http://www.ictwacht.nl = Dutch ICT info
                        http://www.pcwacht.nl = My first
                        both still work in progress, since years.....

                        Peeters


                        pcwacht

                        And here the javascript wich I used:

                        <script language="JavaScript">
                        <!--
                        function
                        popUp(w,h,site) {
                         
                        x = screen.availWidth/2-w/2;
                         
                        y = screen.availHeight/2-h/2;
                         
                        newWin=void(window.open(site,'','resizable=1,width='+w+',height='+h+',top='+y+',left='+x));
                        }
                        //-->
                        </script>


                        Put this somewhere in your header ;)

                        John
                          http://www.ictwacht.nl = Dutch ICT info
                          http://www.pcwacht.nl = My first
                          both still work in progress, since years.....

                          \n\n