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

Answered Slideshow Loop

    • 40088
    • 708 Posts
    Currently a client is using a basic jQuery slideshow that's hardcoded into a template and shows about a dozen images. I need a simple way for them to add/delete images, and add alt text and relative links to each image. Ideally I would like to use the below code as the tpl Chunk (along with TVs) that I could loop, so if they want to add 20 images or delete 7 then it would be no problem.

    <a href="[[*Link TV]]">
    	<img src="[[*Image Picker TV]]" alt="[[*Alt Text TV]]" />
    </a>


    I'm just not sure how to create a loop in MODX.

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

      Todd
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use a listing snippet like getResources and have this in the snippet's chunk tpl:
      <a href="[[+tv.link]]">
          <img src="[[+tv.image]]" alt="[[+tv.text]]" />
      </a>


      For this, I'd use MIGx and its getImageList output snippet. The basic demo in the rtfm will work fine.
        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
        • 40088
        • 708 Posts
        Thanks Susan,

        I created a (MIGX) url inputTVtype to wrap images in a link that point to internal pages (though it doesn't seem to allow for a relative url). While it works ok it requires the client manually type (or copy/paste) the absolute url.

        So, is there a more elegant way to create a (MIGX) inputTVtype field that would allow the user to select the (internal) page they want to link to and have it insert a relative url?

        Revo 2.3
        MIGX 2.8.1 [ed. note: todd.b last edited this post 12 years, 2 months ago.]
          Todd
          • 4172
          • 5,888 Posts
          Quote from: todd.b at Jul 19, 2014, 03:16 PM
          Thanks Susan,

          I created a (MIGX) url inputTVtype to wrap images in a link that point to internal pages (though it doesn't seem to allow for a relative url). While it works ok it requires the client manually type (or copy/paste) the absolute url.

          So, is there a more elegant way to create a (MIGX) inputTVtype field that would allow the user to select the (internal) page they want to link to and have it insert a relative url?

          Revo 2.3
          MIGX 2.8.1

          this is all a matter, of your tpl-chunk

          what is your tpl-chunk?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40088
            • 708 Posts
            This is all I'm using,

            [[!getImageList?
            &tvname=`slideshow`
            &tpl=`@CODE:<a href="[[+link]]"><img src="[[+image]]" alt="[[+alt]]" /></a>`]]
              Todd
              • 4172
              • 5,888 Posts
              if link is a resource-id, you will need

              <a href="[[~[[+link]]]]"><img src="[[+image]]" alt="[[+alt]]" /></a>


              and you will need to put it into a tpl-chunk:

              [[!getImageList?
              &tvname=`slideshow`
              &tpl=`tplLink`]]


              otherwise MODX would try to parse
              [[~[[+link]]]]
              before the placeholder was parsed, which wouldn't work



                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 40088
                • 708 Posts
                Hi Bruno17,

                I believe I did what you suggested correctly but I'm not seeing any difference between your approach and mine. I still have to manually type an absolute url to link to an internal page.

                Instead of using a 'url' inputTVtype I think what I'm hoping to do is to use a picker (listbox) to select a site page and have the relative url generated.

                  Todd
                • discuss.answer
                  • 4172
                  • 5,888 Posts
                  you can use a resource-list-TV-type to get the listbox for picking the resource.
                  This will store the resource-id and MODX will generate the url to that resource with

                  [[~[[+link]]]]


                  if link is the resource-list-field
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 40088
                    • 708 Posts
                    That's excellent, Bruno. Thank you! [ed. note: todd.b last edited this post 12 years, 2 months ago.]
                      Todd