We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38926
    • 33 Posts
    I've spent some days on finding a solution to this, but I guess I'll have no choice by to ask here.

    I've built a small search engine that uses the getResources snippet to get lists of specific resources. Currently I'm doing this by using the tvFilters property to select the proper resources, but now I've run into a situation thats leaving me a bit stumped.

    I'm trying to select resources, based on a tv value or tag value in a child resource.

    So if we say that I'm looking at a resource with id of 1, and the depth I'm looking is also 1 (so we only select the direct children of 1) I'd be looking at 1's 3 children resources with id 2,3 and 4. That's just fine, I can use tvFilters for that, but I want to select 2,3 and 4 based on what is in 2,3 and 4's children resources.

    Lets have their ID stacks like this:
    2->5,6,7
    3->8,9,10
    4->11,12,13

    I've tried with nested getResources calls, but by then it's too late. I need it to filter out a resource from the start.

    I've also tried thinking of putting TV's in 2,3 and 4 that contains a list of their children, but either the syntax is eluding me, or it's simply not possible to dynamically have a TV fetch the children of the resource it is in.

    Are there anyone that have an idea of what I could do? Please don't hesitate to have me clarify my problem if some parts of it sound too vague.
      • 30912
      • 463 Posts
      How ais the tree set up? If the pages you are tryingto select are listed under the parent ie.

      Parent
      >>Child
      >>Child
      >>Child

      Parent
      >>Child
      >>Child
      >>Child

      You could use 'switch' to display it according to the defined parent. or is it something more dynaic your after?
        • 38926
        • 33 Posts
        What is switch? Is that a package?

        The resources that is being looked through is fully dynamic. Which means it can have a variable amount of parents and children with different values.

        fx something like this:

        Parent:(search root. Not included in the results)
        -Site
        --SiteAd
        --SiteAd
        --SiteAd
        -Site
        --SiteAd
        --SiteAd
        -Site
        --SiteAd
        --SiteAd
        --SiteAd
        --SiteAd

        It doesn't go deeper than SiteAd though. There will only be the Site's and the SiteAd's in variable amounts. I'm trying to exlude the Site's from the getResources call through the values the individual SiteAd holds (could be a TV with a size value fx).

        Hope that makes sense.
          • 30912
          • 463 Posts
          Switch is a package yeah,

          It basically sets a sieres of conditional statements.

          http://modx.com/extras/package/switch

          eg:

          [[!switch?    &get=`[[UltimateParent]]`    &c1=`2` &do1=`[[getResources? &parents=`10` &tpl=`one`]]`    &c2=`3` &do2=`[[getResources? &parents=`17` &tpl=`two`]]`        &default=`[[getResources? &parents=`15` &tpl=`default`]]`  ]]   


          So basically if parent = 2 then show everything under 10, if parent =3 then show everthing under 17 if parents are neither display everything under 15

          HTH
            • 38926
            • 33 Posts
            Ah I see. That might work. I'd be checking the value of the child though, to determine if I should get the parent, but I should be able to make it work.

            Will have to wait until monday though wink

            Thank you for your help.