We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Hi, I need to create a TV that can be dynamically populated by a group of resources, not sure on the best approach. Let me explain what needs to happen:

    I'm developing a site that will have several dozen client testimonials, I want to create a group in the resource tree for these testimonials so that the client can add a new resource for each new testimonial. fine - easy enough. Where it gets tricky is that on each page I want to include a testimonial that the client can pick. i.e. they create a new page/resource and in the template variables section there is a pick list/drop down of all the available testimonials.

    So I'm not sure what the best way to handle this is, ideally, create a snippet or chunk or something that uses getResources to retrieve the list of child resources for the testimonials tree & somehow populates that TV on the fly... ?

    - any suggestions?

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 36926
      • 701 Posts
      I've done something similar on an old Evo site but guess the principals are going to be the same. Basically had a recourse that contained a child resources, each of which where a sales contact. The client could add more as and when.

      I created drop down tv and as the input values i had:

      @SELECT pagetitle,id FROM modx_site_content WHERE parent='14' ORDER BY pagetitle ASC
      


      Parent being the resource ID that contained the sales contacts.

        • 3749
        • 24,544 Posts
        Does the client need to see the content of the resources, or would the pagetitle do?

        One way would be to use @EVAL in the TV's Input Option Values field to run a custom snippet (with runSnippet() ) that would grab what you need from those resources and return it. The client could select one from a drop-down list or radio options.
          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
          • 26503
          • 620 Posts
          no - the client only needs to see the resource title... I thought there was a way to reference output from a chunk in a TV?

          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            Have a look at the resourcelist TV input type.

            When in 2.1 it'll give you a bunch of options to fine tune it, in <2.1 I think you need to specify the ID of the parent resource in the input options field.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 26503
              • 620 Posts
              Mark;

              I shake my head every single time I see how easy stuff like this is in modx.
              That works perfectly, all I had to do was setup the resourcelist TV point it at my parent resource and then in my template:

              [[!If? &subject=`[[*ShowTestimonial]]` &operator=`!empty` &then=`[[$TestimonialCallout]]` ]]


              & the chunk

              <div id="testimonial" class="callout">
              [[!getResourceField? &id=`[[*ShowTestimonial]]` &field=`content` ]]
              </div>
              


              Thanks Mark...

              -sean
                *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                Sean Kimball CLP, CLS.
                Technical Director / Sr. Developer | BigBlock Studios
                ._______________________________________________.
                Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                phone/fax: 905-426-5525
                • 18373 ☆ A M B ☆
                • 3,141 Posts
                Hehe, MODX does that smiley

                There's another related tutorial here that makes use of a snippet and @EVAL, though it is aimed at showing multiple resources (in your case, testimonials): http://rtfm.modx.com/display/revolution20/Creating+a+multi-select+box+for+related+pages+in+your+template
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 26503
                  • 620 Posts
                  Thanks Mark... heh-heh... "client proof" smiley I love it...

                  -sean
                    *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                    Sean Kimball CLP, CLS.
                    Technical Director / Sr. Developer | BigBlock Studios
                    ._______________________________________________.
                    Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                    27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                    phone/fax: 905-426-5525
                    • 3749
                    • 24,544 Posts
                    I totally forgot about the resource list TV type (although it's in my book).

                      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