21 Replies Latest reply on Mar 5, 2008 7:53 AM by (Cheryl_James)

    Drop down Menu with Image names

      In the past I have successfully created Drop Down menus on my Insert and Update forms with the list of images from an Image Folder. I did this using David Powers handy dandy buildimagelist function. Now, I'm running into problems.

      On the Insert page I have no problem utilizing the File upload aspect of the Developer's ToolBox.

      But on the Update page, I'd like to have a drop down Menu that has the current uploaded file name showing. I've tried using the buildingImageList which worked in the past but now doesn't work.

      What are my other options for getting the current image to show?
      Can I have a File Upload plus a Menu on the same page?

      I can foresee, at times, a client having an image uploaded but wanting to update it and insert a new one. I've been running into this just in the testing phases.

      Or wanting to change the uploaded image to one that's already uploaded on the server, thus requiring a drop down menu.

      If I keep having my clients upload new images every time even when the image already exists on the server, the server is going to get bogged down.

      Any suggestions or work arounds that you've used would be greatly appreciated.

      Cheryl
        • 1. Re: Drop down Menu with Image names
          Günter Schenk Level 4
          Hi Cheryl,

          ------
          What are my other options for getting the current image to show?
          ------

          I could provide an easy "no dropdown menu required" solution which works fine on single record update forms, would that help ?

          ------
          If I keep having my clients upload new images every time even when the image already exists on the server, the server is going to get bogged down
          ------

          I think my ADDT tutorial "Image & File Upload: overwrite existing file" might be what you´re lookin for:

          http://www.guenter-schenk.com/tutorials/tutorial.php?id=7

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: Drop down Menu with Image names
            Level 1
            Yes, your single Record solution would be helpful. But I also need the drop down menu option. I've been poking around and wondered if the Editable Drop Down Menu could be converted to what I want. Allow them to see the images that are there and if it's not there, Upload a new one?

            I looked at your tutorial and I'll definitely be using it. Thanks for that.

            Cheryl
            • 3. Re: Drop down Menu with Image names
              Günter Schenk Level 4
              Hi Stacy,

              -----
              Allow them to see the images that are there and if it's not there, Upload a new one?
              -----

              I know what you´re talking about (a file list displayed in a dropdown menu), but I don´t think it´s the best possible solution at all -- I´m doing it in a different way on Update Record pages:

              a) adding a "see previously uploaded pics" link near the File Upload field, and make it point to an extra page loaded in a blank window (I´m personally using popup windows for that)

              b) passing the $_GET['id'] ("id" is what your Update Form already receives to determine the record´s Primary Key) URL variable to that page, and...

              c) displaying an ordinary ADDT file respectively image list here

              Clear advantage IMO: your customer will actually *see* the images he once uploaded, what´s certainly better than just displaying meaningless file names.

              waddayathinkofthat ? :-)

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: Drop down Menu with Image names
                Level 1
                So the customer goes to the pop up window, See the image they need, click on it and the page takes them back to the form with the correct image listed?

                If I don't have something in the file upload field, then my database gets off. If there is an image file name in the database it get's removed somehow.
                • 5. Re: Drop down Menu with Image names
                  Level 1
                  Thanks. In the $_GET['id'] statement of the $folderpath - what is the id supposed to represent? The Unique Key of that table?
                  • 6. Re: Drop down Menu with Image names
                    Level 1
                    Never mind, I fixed that. But it's not liking the getColumnValue command.

                    Here's my code.

                    $folderpath = '../winners_circle/images/'.$_GET['ownerID'];
                    $filename = $tNGs->getColumnValue("owner_picture");
                    $overwrite_checkbox_name = $tNG->getColumnValue("overwrite");
                    $overwrite_checkbox_value = 'Y';

                    // application logic
                    $fullpath = $folderpath.'/'.$filename;
                    if (file_exists($fullpath) && $overwrite_checkbox_name == ''.$overwrite_checkbox_value.'') {
                    @chmod($folderpath,0777);
                    @unlink($fullpath);
                    @chmod($folderpath,0755);
                    }
                    • 7. Re: Drop down Menu with Image names
                      Günter Schenk Level 4
                      ---
                      In the $_GET['id'] statement of the $folderpath - what is the id supposed to represent? The Unique Key of that table?
                      ---

                      yes, that´s at least how I organize images in folders. My image folders are always named according to the respective record´s unique Primary Key in order to avoid confusion

                      Cheers,
                      Günter Schenk
                      Adobe Community Expert, Dreamweaver
                      • 8. Re: Drop down Menu with Image names
                        Günter Schenk Level 4
                        ------
                        But it's not liking the getColumnValue command
                        ------

                        and your file field´s name is "owner_picture" ?

                        Cheers,
                        Günter Schenk
                        Adobe Community Expert, Dreamweaver
                        • 10. Re: Drop down Menu with Image names
                          Günter Schenk Level 4
                          So you get some sort of error message like "owner_picture is not part of the transaction" or something ?

                          Cheers,
                          Günter Schenk
                          Adobe Community Expert, Dreamweaver
                          • 11. Re: Drop down Menu with Image names
                            Level 1
                            Notice: Undefined index: ownerID in C:\vhosts\stancik\admin\owner_update.php on line 26

                            Fatal error: Call to undefined method tNG_dispatcher::getColumnValue() in C:\vhosts\stancik\admin\owner_update.php on line 27
                            • 12. Re: Drop down Menu with Image names
                              Günter Schenk Level 4
                              ------
                              Notice: Undefined index: ownerID in C:\vhosts\stancik\admin\owner_update.php on line 26
                              ------

                              assuming that you´re implementing all this on an Update Record form only -- $_GET['ownerID'] is the name of the URL variable your passing to the form from the Dynamic List, correct ?

                              If your form is the usual "insert/edit/delete" one (means it contains ADDT´s Dynamic Form), the URL variable $_GET['ownerID'] doesn´t exist for the Insert Transaction, and when you´re attaching my sample code to an Insert Record transaction, it´s understandable that PHP complains about something it could not detect.

                              In this case you´ll most likely need to use a modified version for the Custom Trigger that´s attached to the Insert Transaction, and IMO the the $_GET['ownerID'] part of the line...

                              $folderpath = '../winners_circle/images/'. $_GET['ownerID'];

                              ...will have to be changed to something else.

                              My question is: do you have such a mixed insert/update/delete form at all, or is it just an Update Record form ? And if it´s a "mixed" form, did you attach this Custom Trigger to both the Insert and the Update transaction maybe ?

                              Cheers,
                              Günter Schenk
                              Adobe Community Expert, Dreamweaver
                              • 13. Re: Drop down Menu with Image names
                                Level 1
                                It's just an Update form.

                                When you click on the Edit link on the previous page and the Update form get's an ownerID, this error doesn't show up. That was my bad. The first error is fine.

                                It's the Fatal error that I don't know what it's about.
                                • 14. Re: Drop down Menu with Image names
                                  Günter Schenk Level 4
                                  ok, that Fatal error could be related to some of the ADDT "includes" files missing. I suggest to "Update Includes folder" from your ADDT Control Panel (what will hopefully add the missing files) and then check if this error has gone.

                                  Cheers,
                                  Günter Schenk
                                  Adobe Community Expert, Dreamweaver
                                  • 15. Re: Drop down Menu with Image names
                                    Level 1
                                    Nope that didn't work. Still getting it.
                                    • 16. Re: Drop down Menu with Image names
                                      Günter Schenk Level 4
                                      Can you please upload the code of your form to your host as text version (e.g. code.txt) and provide a link to this file ?

                                      Cheers,
                                      Günter Schenk
                                      Adobe Community Expert, Dreamweaver
                                      • 17. Re: Drop down Menu with Image names
                                        Level 1
                                        http://www.stancikquarterhorses.com/owner_update.txt

                                        Thank you for your patience.
                                        • 18. Re: Drop down Menu with Image names
                                          Günter Schenk Level 4
                                          I found it -- you have a typo in your Custom Trigger code:

                                          $filename = $tNG s->getColumnValue("owner_picture");

                                          should be:

                                          $filename = $tNG->getColumnValue("owner_picture");

                                          This typo was not in my tutorial :-)

                                          Cheers,
                                          Günter Schenk
                                          Adobe Community Expert, Dreamweaver
                                          • 19. Re: Drop down Menu with Image names
                                            Level 1
                                            Not quite as easy as that. :) I originally typed it exactly as you had it and received this error:

                                            Notice: Undefined variable: tNG in C:\vhosts\stancik\admin\owner_update.php on line 27

                                            Fatal error: Call to a member function getColumnValue() on a non-object in C:\vhosts\stancik\admin\owner_update.php on line 27

                                            That's why I had changed it to the tNGs because I had seen that variable earlier in the page.

                                            Still receiving the above error.
                                            • 20. Re: Drop down Menu with Image names
                                              Günter Schenk Level 4
                                              well, was having a closer look at the complete code you provided, and I see that several things are messed up:

                                              1.

                                              function Trigger_Delete_Existing(&$tNG) {
                                              $uploadObj = new tNG_ImageUpload($tNG);
                                              $uploadObj->setFormFieldName("owner_picture");
                                              $uploadObj->setDbFieldName("owner_picture");
                                              $uploadObj->setFolder("../winners_circle/images/");
                                              $uploadObj->setResize("true", 299, 0);
                                              $uploadObj->setMaxSize(1500);
                                              $uploadObj->setAllowedExtensions("jpg, jpe, jpeg");
                                              $uploadObj->setRename("auto");
                                              return $uploadObj->Execute();
                                              }

                                              for some dubious reason this function actually contains ADDT´s image upload code and not the code I provided -- that, said this function has to contain the trigger:

                                              function Trigger_Delete_Existing(&$tNG) {
                                              // user definable variables
                                              $folderpath = '../winners_circle/images/'.$_GET['ownerID'];
                                              $filename = $tNGs->getColumnValue("owner_picture");
                                              $overwrite_checkbox_name = $tNG->getColumnValue("overwrite");
                                              $overwrite_checkbox_value = 'Y';

                                              // application logic
                                              $fullpath = $folderpath.'/'.$filename;
                                              if (file_exists($fullpath) && $overwrite_checkbox_name == ''.$overwrite_checkbox_value.'') {
                                              @chmod($folderpath,0777);
                                              @unlink($fullpath);
                                              @chmod($folderpath,0755);
                                              }
                                              }

                                              Tipp: custom code like that one will have to be pasted into the Custom Trigger´s textarea which you can access by clicking the Trigger´s "advanced" tab -- thought you knew that already :-)

                                              However, at this point I suggest to recreate the form rather than trying to fix it manually -- as I said, there´s no need to copy/paste ADDT´s image upload code in the Custom Trigger´s textarea, only the code I provided.

                                              Cheers,
                                              Günter Schenk
                                              Adobe Community Expert, Dreamweaver
                                              • 21. Re: Drop down Menu with Image names
                                                Level 1
                                                Okay, didn't realize that was where it needed to go. I had just found the comment line indicating it and put it there.

                                                I will start from scratch. Thanks.