New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • Any assistance would be really appreciated, i'm on deadline. A modx site that i'm working on for a production company has an archive of resources for all of it's films separated into a few parent categories. I want to create a check box TV in a static resource that will getresources all of the archive items (basically movie thumbnails and titles) and allow the user to check which resources to show on that page. I've tried the "listMyResources" method from a tut found here: http://rtfm.modx.com/pages/viewpage.action?pageId=34636241 (multi-select box for related pages), but the TV can't pull resources from several parents, only one; and it doesn't output the image TV, it only seems to spit out the pagetitle and nothing else. Any suggestions? I've actually posted this question a few times with no luck so i thought i'd try one more time.
    • The getResources snippet should meet your needs: The parameter &parents allows several parents, and what it spits out is totally controllable by the parameter &tpl. See:
      http://rtfm.modx.com/display/ADDON/getResources
      • Use Resource List TV input options, you can define multiple parents in there.

        The output of this TV will give you the IDs of selected resources. You will need to process those IDs and format the output as your specification.

        eg.
        [[getResources? &resources=`[[*your-resource-list-tv]]` &......... ]]


        Hope it helps.
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • Thanks for the advice... I need the client to be able to select the individual resources to display on a page in the front end. For instance, if a parent resource contains resources 1-20, they should be able to display resources 2, 3, 7, 9, 12, 14, and 17 on the front end by selecting them in a check box or multi-list TV in another static resource. Therefore, shouldn't the input be check box or multi-select listbox? Please advise.
          • Hmm, looks like I missed the point.

            Well, good news is I have a solution for you.

            I could explain in writing, but these 2 screenshot will give you input checkbox and output as a comma delimited IDs.
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • thanks so much. this works great to grab resources from multiple parents, but the TVs from the selected resources still aren't being outputted (the image tv of the resource, and another custom text resource). only the pagetitle value is spit out. i basically need to output the resource's pagetitle and image-tv to to the front. this is a great start though... any ideas?
              • i believe the problem is the snippet i'm using to spit out the content. should i use getResources to output the selected resources?
                • Which snippet you are using?
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                  • using a custom snippet from the tutorial mentioned above

                    chunk:

                    [[relatedPages? &input=`[[*isNewFilm]]` &tpl=`archive-image-tpl`]]


                    relatedPages snippet:

                    <?php
                    if (empty($input)) { return 'This article is so unique, that we couldn\'t find anything related to it!'; }
                    $tpl = $modx->getOption('tpl',$scriptProperties,'relatedPagesTpl');
                    if ($modx->getChunk($tpl) == '') { return 'We found some related pages, but don\'t know how to present it.'; }
                    $ids = explode(',', $input);
                    $output = array();
                    foreach ($ids as $key => $value) {
                      $resource = $modx->getObject('modResource',array(
                        'published' => 1,
                        'id' => $value));
                    if ($resource instanceof modResource) {
                        $fields = $resource->toArray();
                        $fields['archive-image'] = $resource->getTVValue('archive-image');
                        $output[] = $modx->getChunk($tpl,$fields);
                      }
                    }
                    return implode('',$output);


                    tpl archive-image-tpl:

                    <li class="archive-item">
                    <a href="[[~[[+id]]]]" rel="galerie">
                    <img data-href="[[+tv.archive-image]]" alt="[[+pagetitle]]" src="assets/webapps/jail/_img/fa_loading.gif" width="200" height="281" /></a>
                    <a href="[[~[[+id]]]]"><p><em>[[+pagetitle]]</em> ([[+tv.release-date]])</p></a>
                    </li>


                    archive-image and release-date aren't being processed

                    any help would be greatly appreciated, site has to go live shortly... [ed. note: pjldesign last edited this post 7 years, 4 months ago.]
                    • got it! had to include placeholder in the chunk holding the relatedPages snippet.

                      chunk:

                      [[relatedPages? &input=`[[*isNewFilm]]` &tpl=`archive-image-tpl`]]
                      [[+archive-image]]


                      whew!