We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2057
    • 12 Posts
    I am trying to make a product page where I can show one normal image, all the thumbnails, and provide a popup window to view the big version. I tried to combine the two techniques in the wiki (Picture_and_thumbnails_on_same_page and Open popup with prev/next links), but I can’t get it to work. The closest I came was being able to open the popup with the first image in the gallery, but i couldn’t get the javascript to update the URL to the picture that was currently being viewed.

    If I could get the slidebox or slimbox to work with the big images, that would be great too. Has anyone done this before or something similar? What technique did you use?

    Here are my snippet calls:
    [!MaxiGallery? &galleryPictureTpl=`mgGalleryPicture` &js=`mgJs` &manage_target=`58`!]
    [!MaxiGallery? &js=`mgJsPop` &galleryPictureTpl=`mgGalleryPicture2` &picture_target=`61` &limit=`1`!]


    I can provide more info if needed to see if I can get this working.
      • 7923
      • 4,213 Posts
      You need to do following things:

      1. Add parameter to the showPic function for picture ID.
      2. Add link to the picture element, eg. around <img id="maxImage"... with some ID.
      3. Create a custom pictureTpl to the popup document (the one that has [!MaxiGallery? &is_target=`1`!] call) where you show the bigger image instead of the normal one.. eg. add "big_" prefix to the [+maxigallery.picture.filename+] placeholder.
      4. Change the showPic function so that after the image is swapped, it will also update the links onClick attribute value so that it will link to the big image, eg. javascript:openWindow(’url_to_the_popup_document.html?pic=’+picId); where picId is the variable that holds the picture id what you have added to the function.

      That should work..

      EDIT: actually, you may need to add &display=`pictureview` to the call that is in the popup document (same as in step 3).


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 2057
        • 12 Posts
        1. Add parameter to the showPic function for picture ID.
        How do I get the picId parameter set? I think I understand the rest of it, but I’m stuck on this step.
        2. Add link to the picture element, eg. around <img id="maxImage"... with some ID.
        like this?
        <a href="javascript:void(0);" onClick="javascript:openWindow('[+maxigallery.picture_link_url+]');return
        false;" id=maxImageId><img id="maxImage"
        src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]"
        alt="[+maxigallery.picture.title:htmlent+]" /></a>
        


        Thanks!
          • 7923
          • 4,213 Posts
          Quote from: arielmango at Dec 09, 2007, 08:30 PM

          1. Add parameter to the showPic function for picture ID.
          How do I get the picId parameter set? I think I understand the rest of it, but I’m stuck on this step.
          You add picId variable to the javascript function, and in your custom maxigallery galleryPictureTpl template where it creates the links to change the picture, you use [+maxigallery.picture.id+] as the value for the picId parameter..
          Quote from: arielmango at Dec 09, 2007, 08:30 PM

          2. Add link to the picture element, eg. around <img id="maxImage"... with some ID.
          like this?
          <a href="javascript:void(0);" onClick="javascript:openWindow('[+maxigallery.picture_link_url+]');return
          false;" id=maxImageId><img id="maxImage"
          src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]"
          alt="[+maxigallery.picture.title:htmlent+]" /></a>
          

          Well.. yes, but the link by default should be url to the first picture that opens when the gallery page is viewed, eg. [~document_id_of_the_popup_document~]?pic=picture_id_of_the_first_picture. And also put double quotes around the id attribute value smiley


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 2057
            • 12 Posts
            Ok!  I’ve made progress.  The only thing I can’t figure out now is how to modify the javascript code to
            4. Change the showPic function so that after the image is swapped, it will also update the links onClick attribute value so that it will link to the big image, eg. javascript:openWindow(’url_to_the_popup_document.html?pic=’+picId); where picId is the variable that holds the picture id what you have added to the function.

            I’ve got everything else working but when I click on the normal size image it always goes to the first image (regardless of which image is being displayed).  I know this is because the pic id is not being updated.
            <div class="picturecontainer">
            <a href="javascript:void(0);" onClick="javascript:openWindow('[~61~]?gal_id=[+maxigallery.picture.gal_id+]&pic=[+maxigallery.picture.id+]');return
            false;" id="maxImageId">
                   <img id="maxImage"
            src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]"
            alt="[+maxigallery.picture.title:htmlent+]" /></a>
                   <p id="maxTitle">[+maxigallery.picture.title:htmlent+]</p>
                   <p id="maxDescr">[+maxigallery.picture.descr:htmlent+]</p>
            </div>


            here is the modified showPic
            <script type="text/javascript">
            function showPic(url,title,descr,width,height,picid) {
                   var img = document.getElementById('maxImage');
                   var picid = document.getElementById('maxImageId');
                   var titleHolder = document.getElementById('maxTitle');
                   var descrHolder = document.getElementById('maxDescr');
                   img.src=url;
                   img.width=width;
                   img.height=height;
                   if (titleHolder != null) {
                           for (var i = 0; i < titleHolder.childNodes.length; i++) {
                                   titleHolder.removeChild(titleHolder.childNodes[i]);
                           };
                           if (title != "") {
                                   var node=document.createTextNode(title);
                           }
                           else {
                                   var node=document.createTextNode("");
                           }
                           titleHolder.appendChild(node);
                   }
                   if (descrHolder != null) {
                           for (var i = 0; i < descrHolder.childNodes.length; i++) {
                                   descrHolder.removeChild(descrHolder.childNodes[i]);
                           };
                           if (descr != "") {
                                   var node=document.createTextNode(descr);
                           }
                           else {
                                   var node=document.createTextNode("");
                           }
                           descrHolder.appendChild(node);
                   }
            }
            </script>




              • 7923
              • 4,213 Posts
              var piclinkid = document.getElementById('maxImageId');
              piclinkid.onclick = function() {openWindow('[~61~]?&pic='+picid)}
              


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 2057
                • 12 Posts
                First, thanks for your help. I must be missing something. This should work, but it turns out that my picid value is not being picked up after all. It is being displayed in the source for the thumbnails, but I guess I’m not setting my variable right. I just don’t have enough javascript experience to figure out where I went wrong.
                var picid = document.getElementById('maxImageId');
                just returns javascript:void(0); when used in the url. So how do I get the pic id from here
                 <a href="javascript:void(0);"
                onClick="javascript:showPic('[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]','[+maxigallery.picture.title:htmlent+]','[+maxigallery.picture.descr:htmlent+]',[+maxigallery.picture_width_normal+],[+maxigallery.picture_height_normal+],[+maxigallery.picture.id+]);return
                false;">

                to my showPic function at the top?

                Or another question... are there any pre-built gallery functions that use all three picture sizes? You can be sure if I do ever get this working I will add the instructions to the wiki. smiley

                  • 7923
                  • 4,213 Posts
                  You use the "picid" variable name twice in your showPic js function.. it’s already in the parameters as a variable name, so use another variable name when getting the link element.. like in my post, i used var piclinkid..

                  EDIT: Oh and the tree picture sizes are only used in normal gallery display mode when &keep_big=`1`.. the big image is linked to from the normal size picture.


                    "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                    • 2057
                    • 12 Posts
                    Ok, that worked!  I will post the complete instructions to the wiki. Thank you!
                      • 7923
                      • 4,213 Posts
                      Quote from: arielmango at Dec 11, 2007, 09:27 AM

                      Ok, that worked! I will post the complete instructions to the wiki. Thank you!
                      Ok, that’s great, thanks!


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."