We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    with that nice, very useful snippet, how could I place (with that [[ xx ]] style) a single (defined) picture out of a given gallery? It’s for presentation consistence and economy.
    Maybe something like a third value with << &type= [ "random" | "latest" | "name (or id)" ] >> in mgSolo. Or something else.
      • 7923
      • 4,213 Posts
      if you want just a specific image, use the straight url of that image.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        I was just fussing over that the other day! I have a series of before/after galleries, each a set of 3 before and 3 after pictures. On the main page introducing the gallery, I wanted the first picture of the "after" set of three; this would always be the 4th picture in the gallery. The client will be adding more galleries, and their filenames have no consistancy or organization at all, so it needs to be dynamic.

        I almost figured out the hack to do that; add bit of code so that if the "type" value was numeric select only that image from the given gallery. I think it will need a conditional to choose between two different database queries. I’ll be getting back to that later today.
          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
          • 7923
          • 4,213 Posts
          If you know that the picture is always the 4th picture in each gallery with some certain sort order, take the SVN version, it has offset and limit parameters that you could use then, so for example you could do this in Ditto template that lists all the gallery documents:

          [!MaxiGallery? &view_gallery=`[+id+]` &order_by=`date` &order_direction=`DESC` &offset=`3` &limit=`1`!]


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Very nice!

            Except that I find that childgalleries works even better for what I need. I just move the after trio to before the before trio, and it grabs the first image, which happens to be the one I want.

            Now to figure out the template system since there’s no longer an option to get rid of the manage button.
              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
              • 7923
              • 4,213 Posts
              To get rid of the manage pictures button, do a custom galleryOuterTpl that doesn’t have it.. for example just copy the default template content to a chunk and remove that [+maxigallery.managebutton+] parts from the top.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Already done wink
                  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
                  • 21800
                  • 174 Posts
                  is it so hard to do as proposed in the first post here? In the resources pages of the modx site for example, do they have a folder for each single image?
                    • 7455
                    • 2,204 Posts
                    Quote from: nos at Feb 20, 2007, 04:33 AM

                    is it so hard to do as proposed in the first post here? In the resources pages of the modx site for example, do they have a folder for each single image?

                    here you go slapt a small snippet togetter for you
                    Use the one below


                    Greets Dimmy
                      follow me on twitter: @dimmy01
                      • 1511
                      • 144 Posts
                      Dimmy thanks, it was just the thing I was looking for. wink

                      I also corrected the hardcoded stuff. Also included are all the necessary scripts for lightboxv2 and a parameter added (align).
                      The code is also modified since I do not use the title/description for the images but the description alone.

                      This is a minor correction anybody can customize for his own needs.

                      <?php
                      ////////////////////////////////////////////////////
                      // GrabMGImage
                      // Made by Dimmy, modified by andrazk
                      // grabs a image from Maxigallery by using gal id and image id
                      // use like this [!GrabMGImage?&galid=`1`&id=`5`&align=`left`!]
                      // if galid is not set it wil use curent document
                      // 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,(you will need to add the js link yourself.
                      // 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;
                      $galid = isset($galid)?$galid:$modx->documentIdentifier;
                      $align = isset($align)?$align:'';
                      $id = isset($id)? $id : 1;
                      
                      $folder="assets/galleries/".$galid."/";
                      $result = $modx->db->select("*", $modx->getFullTableName('maxigallery')," id='".$id."'"); 
                      $info = $modx->db->getRow($result);
                      $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;
                      ?>