We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27708 MODX Staff
    • 2,502 Posts
    Hey all,

    I am using MG to generate a random image from the galleries. I am able to do this sucessfully with the following call:

    [!MaxiGallery? &gal_query_ids=`all` &order_by=`random` &limit=`1` &galleryPictureTpl=`mgGalPicTpl`!]


    The template I have created is based on the default galleryPictureTpl as follows:

    <div class="imageElement">
    	<a href="[(base_url)][+maxigallery.index_url+]" title="[+maxigallery.strings.go_to_gallery+]">
    	<img src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]" class="full" /></a>
    </div>


    What I can’t seem to get to work is a link to the parent gallery of the image shown. I don’t know if this is possible. With the above call, the link is actually not generating to anything other than / and I can’t figure that out.
      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
      • 3749
      • 24,544 Posts
      I’m not sure if this is what you want but I did it this way and it works. I just created the following chunk and put {{MyChunk}} in the template:

       [[MaxiGallery? &gal_query_ids=`all` &query_level_limit=`5` &order_by=`random` &limit=`1` &pics_per_row=`1` &max_thumb_size=`110`  &thumb_use_dropshadow=`1` &galleryPictureTpl=`mgPicture`]]
      


      It pulls a random picture from all my galleries and clicking on it links to the gallery that picture is in. I think it would still work if you only had one gallery.

      Bob


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7923
        • 4,213 Posts
        The link in your galleryPictureTpl should be:

        <a href="[~[+maxigallery.picture.gal_id+]~]" title="[+maxigallery.strings.go_to_gallery+]">


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