We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47562
    • 113 Posts
    Howdy.

    I'm trying to figure out what the where clause looks like to select those pages that have rel="learn".

    Tried placing the following line in the params array passed via $modx->runSnippet('getResources', $params):

    'where' => '{"rel:=":"learn"}'

    but that doesn't result in what I'm looking for, which is just the set of pages with that given rel setting.

    Can anyone shed light on what I should be using?

    Thanks!

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

      • 30585
      • 833 Posts
      There are no columns named "rel" in the modx_site_content table. The &where will only filter records if columns you specify exist.
        A MODx Fanatic
        • 47562
        • 113 Posts
        Yes, that's right. So I take it I'll have to check for a substring "learn" within the link_attributes? (And what would that where clause look like?)
          • 30585
          • 833 Posts
          Maybe with a custom snippet, but I don't think getResources would help with your problem as described. Why not store your "rel" data in a TV and use &tvFilters=`mytv==%a`?
            A MODx Fanatic
            • 47562
            • 113 Posts
            Thanks treigh.

            Yes, I may have to look into other ways of doing this. Basically, I'm looking for an easy way for the client to designate pages that can be targeted by a "learn more" button; the MigX sub-tv for this learn page could then just be a single-select listbox containing just these designated pages. At least, that was what I was trying for... smiley

            Can you provide a bit more detail on how you'd approach something like this?

            Thanks again for the help.
            • discuss.answer
              • 30585
              • 833 Posts
              I definitely think you can use a TV for this.

              You could create a Single-Select Listbox TV and assign the possible values your TV could have and attach it to the Template you want getResources to filter.

              TV Name:
              LinkRel

              Input Option Values:
              Learn more==more||Option 2==value2

              You can then modify your getResources call like this:

              [[getResources? &parents=`xxx` &tpl=`myRowTpl` &tvFilters=`LinkRel==%more%` &includeTVs=`1` &includeTVList=`LinkRel`]]
              

              this would return all resources that have the LinkRel TV value set to "more".
              The use of &includeTVList is encouraged for performance reasons

              I hope this helps
                A MODx Fanatic
                • 47562
                • 113 Posts
                Yup, that will work quite well. Thanks a million! smiley
                  • 30585
                  • 833 Posts
                  Glad I could help.
                    A MODx Fanatic