We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42049 ☆ A M B ☆
    • 250 Posts
    Firstly, I do have a working solution, my main question here is, can it be optimized to reduce the number of chunks/calls required.

    Imagine that I have several resources, each contains unique migx tv values.

    What I want to accomplish is a page, that lists the first tv value from each of those resources.

    The way that I currently have this working is :

    1. getResouces specify parent, limit and a template chunk,
    2. In the template chunk i make a getImageList call, specifying the doc id as [[+id]], the limit (1) and another template chunk
    3. In the 2nd template chunk create my html that is rendered.

    Is there a smarter way of doing this?
      GEL STUDIOS
      MODX Professional | MODX Ambassador

      Website | Email | Twitter | Facebook
      • 4172
      • 5,888 Posts
      this is the way to go without some custom-coding.
      Of course its possible to create a custom-snippet, which does that all in one.
      what is the code of your chunks currently?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42049 ☆ A M B ☆
        • 250 Posts
        1st call to getResources
        [[!getResources? 
          	&tpl=`getFirst`
          	&includeTVs=`1`
          	&processTVs=`1`
        ]]

        Inside tpl 'getFirst' which calls to getImageList :
        [[!getImageList?
            &docid=`[[+id]]`
            &limit=`1`
            &tvname=`gallery`
            &tpl=`render`
        ]]

        and finally tpl 'render' :
        <img src="[[+image]]" alt="[[+title]]"/>
          GEL STUDIOS
          MODX Professional | MODX Ambassador

          Website | Email | Twitter | Facebook
          • 38878
          • 255 Posts
          Your issue looks similar to one I had with the Gallery addon where I needed to group galleries by category and list the categories each with its own cover image. In my struggles I discovered a little known (at least I'd never seen it) feature of parent/child galleries where galleries can be in a hierarchy (drag and drop in the gallery manager). I created parent galleries marked prominent for each category I needed with one image each, list them all with one gallery call filtering on prominent and a different chunk to show the cover image and description of the parent ( you can also add previews of each child as you normally would do on the main gallery resource but I didn't). No custom snippets, just one new chunk call to format the 1st level galleries (or categories) and another to format the children of it called galleryAlbums.

          Of course if you're not using the gallery addon, this probably won't help. But I saw your reference to "gallery" in your code and took a stab. The beauty is once this was set up the whole thing is manageable through the gallery back end with no need for clients to manage multiple resources or TVs to create new categories or move them around.
            • 42049 ☆ A M B ☆
            • 250 Posts
            The reason I'm even asking this question is because I'm planning to do a screencast of creating a simple client editable gallery, that uses migx, phpthumb and getResources. Including the settings up of MIGX.

            I will for the moment, just make another simple IMG TV and set that as the gallerys cover photo, I will explain both methods in the cast just to make sure everyone is on the same page smiley
              GEL STUDIOS
              MODX Professional | MODX Ambassador

              Website | Email | Twitter | Facebook
              • 38878
              • 255 Posts
              Yeah, so no gallery mod;) Disregard;)