We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46396
    • 14 Posts
    I have a parent page of multiple child pages; each child page has two TVs, each TV has tags key-words.
    I want to retrieve the child pages that have a keyword tag in any TV and display it in the parent page.
    thanks a lot.

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

    • discuss.answer
      • 30585
      • 833 Posts
      Use getResources.

      Here's a working example for you, assuming I understood your question:

      [[getResources? 
        &parents=`[[*id]]` 
        &tpl=`myRowTpl`
        &includeTVs=`1`
        &includeTVList=`enter a Comma-delimited list of your TemplateVar names`
        &tvFilters=`myTV==%keyword%||myTV2==%keyword%`
      ]]

      Place this call on your parent resource and it will match and list all child resources that have the specified keyword in those two TVs (See &tvFilters above). Make all appropriate adjustments that suit your needs.

      Head over to the docs and have a look at getResources: http://rtfm.modx.com/extras/revo/getresources
        A MODx Fanatic
        • 3749
        • 24,544 Posts
        Can you be more specific about what you want to display from the child pages? You probably don't want the whole page, template, TVs and all, so what *do* you want?
          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
          • 46396
          • 14 Posts
          thank you for your help
          the answer given by treigh it works well
            • 30585
            • 833 Posts
            I'm glad I could help.
              A MODx Fanatic
              • 46396
              • 14 Posts
              I used the answer given by treigh to solve my problem.
              now I want to store the IDs children returnd in the first time in a temporary variable
              in the second stage,
              this varaible will be used to retrieve other children pages with another keyword but they are not returned in the first stage

              in fact, the children pages can have a common keywords.
              how I can do ?
              thank you for your help
                • 3749
                • 24,544 Posts
                I want to store the IDs children returned in the first time in a temporary variable in the second stage, this variable will be used to retrieve other children pages with another keyword but they are not returned in the first stage

                I don't understand how you can retrieve children that were not retrieved in the first pass by storing the IDs of children that were. I also don't see why you need two passes, since you should be able to add to line 6 of Treigh's example and get all the resources you want in one pass.

                In any case, a dedicated snippet would be a lot faster, but we'd need to know more about what is supposed to happen in these two passes (for example, are all the resources to be mixed in one list, or presented in two separate lists?).

                Also, a couple of questions about the TV values:

                1. Are any of the TVs set to their default value (it's faster if none are).
                2. Can you use the raw values of the TVs for your search without processing them? (It's faster if you can.)



                  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