We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30912
    • 463 Posts
    Morning,

    So I have managed to sort out a dynamic gallery selector using a Select Box TV with the code:

    @EVAL return 'Choose Gallery'.$modx->runSnippet('GalleryAlbums',array('limit'=>'100','prominentOnly'=>'0','rowTpl'=>'galleryoption'));


    and the chunk of

    ||[[+name]]==[[+id]]


    However, I want to provide a TV with a list of the images within the said gallery but i'm not sure how I would;

    a: select the gallery in question
    b: format the output chunk to make the slection legible (i dont think select Tv's can take image outputs?)

    Any ideas?

    Many thanks

    This question has been answered by Tyreal2012. See the first response.

    • Sounds like a job for MIGx. Basically you need a MIGx grid that is a select dropdown or perhaps checkboxes, with each row item being an image TV. I know I've seen something similar before.
        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
        • 30912
        • 463 Posts
        Hi Susan,

        I thought about that but im specifically using the Gallery extra to control the gallerys rather than MIGx

        I've used MIGx to similar degrees before, but for this its not viable.

        Thanks
          • 52634
          • 60 Posts
          Interested in this as well. Gallery comes with similar TV - galleryalbumlist. But there is unfortunately not a simple TV type which allows to give an explicit gallery album in input options and then have the user only to choose from those images in a comfortable way from a list/set of images. The galleryitem tvtype is not a choice for me: to many clicks to simply choose one image and I do not want those extra styling stuff.
            • 40045
            • 534 Posts
            I actually did something like that to select icons, looks like this



            and the following code is used with @EVAL return $modx->runSnippet('snippetName'); to set the input options, I adopted it a bit to fit the scenario of that thread, intersted if it works =):

            $output = 'Choose image...==';
            // the thumbTpl chunk would be something like ||<span style="background-image: url([[+thumb]]);"></span>==[[+image]] maybe you also have to use [[+image_absolute]] instead of [[+image]]
            $output .= $modx->runSnippet('Gallery', array('album' => 'albumID', 'thumbTpl' => 'chunkName', 'thumbWidth' => '50', 'thumbHeight' => '50', 'imageWidth' => '1000', 'imageHeight' => '1000'));
            
            return $output;
            


            the only problem I have with this solution is that when an image would be selected, it' shows that ugly span tag in the selectbox, and not the url/value/image...
              • 30912
              • 463 Posts
              I actually forgot about this post.

              thanks for the replies, ive taken to just telling the user to select the Id of the image in the gallery.
                • 30912
                • 463 Posts
                Update

                This has come around again, however its not quite working still as you cannot dynamically select the albumID from within a snippet.

                exide, I have this for the snippet GalleryThumbs:

                $output = 'Choose image...==';
                
                $output .= $modx->runSnippet('Gallery', array('album' => '64', 'thumbTpl' => 'TVGalThumb'));
                 
                return $output;


                In this case i specificcally set the album value to 64

                TVGalThumb chunk

                ||<img src="[[+image_absolute:phpthumbof=`&w=100&h=100`]]">==[[+image_absolute]]


                Primary Image TV - single select tv

                @EVAL return $modx->runSnippet('GalleryThumbs');


                The only downside is when you actuakly edit the page you dont see the thumb in the TV, you see the URL to the thumb generated but the images are there on the drop down (which is the important thing right?)

                When you just add the TV to the template (called PrimaryImage for exmaple purposes) you can output as

                <img src="[[*PrimaryImage:phpthumbof=`&w=400&h=400`]]


                For reference I am using pThumb for the phpthumbof outputs, without it it will output the raw image.

                The only lacking at present is the dynamic Gallery select, if you could pass a Gallery Id over to the GalleryThumbs snippet it would work like a dream.



                  • 4172
                  • 5,888 Posts
                  what about not storing the image-path, but just the id?

                  ||<img src="[[+image_absolute:phpthumbof=`&w=100&h=100`]]">==[[+id]]


                  not sure, if [[+id]] is the correct placeholder for the image-record

                  I think, this way you can get the image and gallery of that image in the frontend, because knowing the image-id
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 4172
                    • 5,888 Posts
                    sorry, I think, I see your issue now.

                    Your are asking for a first selectbox, where you can select a gallery and a second one to select a image from that gallery.
                    right?

                    Then my dynamicDropdown-TV should work.
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 30912
                      • 463 Posts
                      Thanks Bruno, I will have a nosey, and the absolute url was just for testing purposes to ensure the path was correct

                      Edit: Bruno, is the Dropdown Tv in the repo? I can only find the github.

                      [ed. note: Tyreal2012 last edited this post 10 years, 5 months ago.]