We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    andrazk Nice work on the mod I indeed notice some flaws in my code (maybe because it was slapt togetter in 10 minutes hehe)

    I made a small modification. because the imageid is a unique id the galid is not needed anymore. for the creation of the url It now grabs the gallery id from the database.

    greets Dimmy
    <?php
    ////////////////////////////////////////////////////
    // GrabMGImage
    // Made by Dimmy, modified by andrazk, modifed again by Dimmy (galid not needed anymore)
    // grabs a image from Maxigallery by using the image id
    // use like this [!GrabMGImage?&id=`5`&align=`left`!]
    // 
    // optional options are &thumb wil display the thumb version &imgtag will generate an imgtag, 
    // align parameter will align the img 
    // when both are set to 1 you wil get a thumb with a lik to the normal image including lightbox tags
    // when thumb is set to 1 and imgtag to 0 it wil display the thumb without as link
    // when both are set to 0 it wil only give the image path
    // when thumb is set to 0 and imgtag to 1 it wil display the normal image.
    // when both are not use at all it wil display the normal image.
    /////
    
    $thumb = isset($thumb)?$thumb:1;
    $imgtag = isset($imgtag)?$imgtag:1;
    $align = isset($align)?$align:'';
    $id = isset($id)? $id : 1;
    
    
    $result = $modx->db->select("*", $modx->getFullTableName('maxigallery')," id='".$id."'"); 
    $info = $modx->db->getRow($result);
    $folder="assets/galleries/".$info['gal_id']."/";
    $title = trim($info['title']);
    $imagename=$info['filename'];
    $description = trim($info['descr']);
    if($thumb == 1) {
    $filename= "tn_".$imagename;
    }else{
    $filename= $imagename;
    }
    
    
            //lightbox scripts
            $lightboxv2_css_link = '<link rel="stylesheet" href="' . $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/css/lightbox.css" type="text/css" media="screen" />';
            $lightboxv2_script_link1 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox_setup.js'; 
            $lightboxv2_settings = 'assets/snippets/maxigallery/lightboxv2/js/lightbox_lang_'.$this->mgconfig['lang'].'.js';
            if(file_exists($modx->config['base_path'].$lightboxv2_settings)){
                $lightboxv2_script_link2 = $modx->config['base_url'] . $lightboxv2_settings;
            }else{
                $lightboxv2_script_link2 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox_lang_en.js';
            }
            $lightboxv2_script_link3 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/prototype.js';
            $lightboxv2_script_link4 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/scriptaculous.js?load=effects';
            $lightboxv2_script_link5 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox.js';
    
            $modx->regClientCSS($lightboxv2_css_link);
            $modx->regClientStartupScript($lightboxv2_script_link1);
            $modx->regClientStartupScript($lightboxv2_script_link2);
            $modx->regClientStartupScript($lightboxv2_script_link3);
            $modx->regClientStartupScript($lightboxv2_script_link4);
            $modx->regClientStartupScript($lightboxv2_script_link5);
    
    
    $al = $align == '' ? $align : 'align="'.$align.'"';
    
    if(($thumb == 1)&&($imgtag==1)) {
    $output="<a href='[(site_url)]".$folder.$info['filename']."' rel='lightbox[maxigallery]' title='".$description."'><img ".$al." src='".$folder.$filename."' title='".$description."' alt='".$description."' class='thumbnail' /></a>";
    }
    
    if(($thumb == 0)&&($imgtag==1)) {
    $output="<img ".$al." src='".$folder.$filename."' title='".$description."' alt='".$description."' />";
    }
    
    if(($thumb == 0)&&($imgtag==0)) {
    $output=$folder.$filename;
    }
    
    if(($thumb == 1)&&($imgtag==0)) {
    $output="<img ".$al." src='".$folder.$filename."' title='".$description."' alt='".$description."' class='thumbnail' /></a>";
    }
    return $output;
    ?>
    

      follow me on twitter: @dimmy01
      • 1511
      • 144 Posts
      Well, I’ve modified the snippet to work with slidebox effect too.

      There are some more modifications concerning the javascript files but the rest is similar to the snippet already shown.

      First, you must adjust the rel="" attribute of the <a href=""... rel=""></a> tag in the snippet.

      Instead of
      $output="<a href='[(site_url)]".$folder.$info['filename']."' rel='lightbox[maxigallery]' title='".$description."'><img ".$al." src='".$folder.$filename."' title='".$description."' alt='".$description."' class='thumbnail' /></a>";
      write
      $output="<a href='[(site_url)]".$folder.$info['filename']."' rel='lightbox_".$folder."/gallery' title='".$description."'><img ".$al." src='".$folder.$filename."' title='".$description."' alt='".$description."' class='thumbnail' /></a>";


      When invoking the slidebox script, it reads the whole gallery.xml, thus showing you all the pictures in the gallery. So you must take care of the prev/next links and the picture number.
      So, make a copy of assets/snippets/maxigallery/slidebox/slidebox.js and rename it to mySlidebox.js.

      Edit it, remove or comment out the lines 159-215
               //  Add next link
               if (i < (all_source.length - 1)) {
                  var next_node     = all_source[i+1];
                  var next_href = next_node.getAttribute("id");
      		.
      		.
      		.
      	//  Add number
      	var number_elm = node.getElementsByTagName("number");
      	var number     = document.createTextNode
      		(number_elm[0].firstChild.nodeValue);
      	objNumber.appendChild(number);
      
      
      

      This will remove the prev/next link and the image number.
      Save the file and upload it to the server.

      Then, in the snippet, change the line
              $slidebox_script_link4 = $modx->config['base_url'] . 'assets/snippets/maxigallery/slidebox/slidebox.js';
      with
              $slidebox_script_link4 = $modx->config['base_url'] . 'assets/snippets/maxigallery/slidebox/mySlidebox.js';


      To be really thorough, make a copy of the slidebox_lang_en.js, rename it, change the contents accordingly and change the call the same way as for the file above.

        • 7923
        • 4,213 Posts
        Just to let you know at this point until this goes too far, the next version will be possible to do everything that maxigallerysolo does and also possible to retrieve singe pics by picture id.. The output is of course fully templateable. I should have the RC done today..


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 1511
          • 144 Posts
          Thanks for the "warning". grin
          But I’m going live with a site in a few days and I needed this functionality now. So, why not share it.
            • 7923
            • 4,213 Posts
            Yes, this is a good resource to have in any case, and when I got the RC ready, you would still have to learn about the new parameters etc to make what you want, so it’s good to have this available too. Thanks for doing it.


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 7455
              • 2,204 Posts
              Well its good to see people interact with eachother to create.

              I learned a lot by "hacking" snippets for my needs.

              Greets Dimmy
                follow me on twitter: @dimmy01
                • 21800
                • 174 Posts
                just found this in the jungle of this forum:

                "
                added on MaxiGallerySolo some stuff that somebody may need. They are:

                Type
                DIRECT - Call the picture by its ID;
                OLDEST - Call the oldest picture;
                POS - Call the picture by it’s position (which you can configure always).

                New variables
                ORDER_POS - ASCending or DESCending for POS type
                PID - What’s the picture’s ID
                "
                here:
                http://modxcms.com/forums/index.php?PHPSESSID=f29d7a9f411deeb115988f4d24f86d67&topic=11806.0;wap2
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Yeah, MODx is getting to be a real adventure! grin
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 14779
                    • 256 Posts
                    Is there a way I can use lightbox to display a different picture when a user clicks a thumbnail on my site?
                      PM me to find out how you can get a FREE ipad 2!
                      • 7923
                      • 4,213 Posts
                      Could you explain more?

                      Are you using MaxiGallery? Where does the thumbnail come? What image you would like to show? etc..

                      Lightbox simply shows the image that is defined in the link tag href attribute. So if you are using MaxiGallery, you can create a custom template and make the picture link tags point to some other picture than the default.


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