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

    I'm trying to filter my resources with getResources' tvFilters. Say, i have a TV called "myTV" in a numeric format and want to get only TV with value "6".

    [[getResources &tvFilters=`myTv==6`]] works just fine.
    [[getResources &tvFilters=`myTv==@EVAL return 6;`]] doesn't work, and I can't figure out why.

    Actually, I'm trying to get some data form $_POST, like this:
    [[getResources &tvFilters=`myTv==@EVAL return $_POST['myTV'];`]] , but no success.

    What do I do incorrectly?
      • 49529
      • 196 Posts
      ОК, I dealt with it.

      getResources stores all TV as strings, so when we compare inside this snippet, we should sure that all our values a strings. I made a very short snippet [[post]]:

      <?php
      $myTV = $_POST['myTV'];
      return (string) $myTV;


      and call it:

      [[getResources &tvFilters=`myTv==[[post]]`]]


      Hope this will help somebody.

        • 41647
        • 49 Posts
        How about setting the POST-params as placeholders on the top of the page?

        $post = $modx->request->getParameters(array(), 'POST');
        $modx->setPlaceholders($post, 'post.');


        So your call could look like this:

        [[getResources &tvFilters=`myTv==[[+post.myTv]]`]]
          • 49529
          • 196 Posts
          Just another little add:

          spaces in getResources comparision are not allowed
          [[getResources &tvFilters=`myTv==[[+post.myTv]]`]]
          

          it's OK

          [[getResources &tvFilters=`myTv == [[+post.myTv]]`]]
          


          this will not work