We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20865
    • 30 Posts
    Hello everyone.
    I have some troubles with "possible TV values".
    I have a drop-down box in wich I want to have [[+pagetitle]]==[[+id]]||(in chunk i have this code)
    I’m trying to run getResources.
    My code in TV :
    @EVAL 
    $params['parents']='6';
    $params['depth']='0';
    $params['tpl']='roomstournirs';
    $params['limit']='500';
    $output= $modx->runSnippet("getResources", $params);
    return $output;
    

    If just run in chunk
    [[!getResources ? &parents=`6` &depth=`0` &tpl=`roomstournirs`]] 

    I will get something like this :
    test5==22|| test==18|| test2==19|| test3==20|| test4==21||

    Params are transferring and $output is working, i have tested it with :
    @EVAL 
    $params['asd']='asd';
    $params['qwe']='qwe';
    $output= $modx->runSnippet("test", $params);
    return $output;

    in test i have this code, and it works :
    return $qwe."||test||".$asd;​

    So, can anybody tell me why getResources in @EVAL isn’t working and how to solve this problem.
      • 20865
      • 30 Posts
      Solved this with
      $temp= $modx->db->query("Select * From `modx_site_content` WHERE template=11");
      while($row = $modx->db->getRow($temp))
            {
                $res .= $row['pagetitle']."==".$row['id']."||";
            }
      return $res;​

      and
      @EVAL
      $output= $modx->runSnippet("test");
      return $output;

      But i think there must be a way to do this with getResources.
        • 11076
        • 159 Posts
        I Think it should be (yeah it’s the same but in one line):
        @EVAL return $modx->runSnippet('getResources',array('parents' =>'6', 'depth' =>'0', 'tpl' =>'roomstournirs', 'limit' => '500'));
        


        you can also use directly the @SELECT binding instead of running a query by a snippet,
        without the limit of 500 you’ve used you even could do the shortcut of using a resource-list type.

        BTW, if you’re using getResources, you can set the last tpl to be without the ’||’ delimiter.
          Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
          • 20865
          • 30 Posts
          @EVAL return $modx->runSnippet(’getResources’,array(’parents’ =>’6’, ’depth’ =>’0’, ’tpl’ =>’roomstournirs’, ’limit’ => ’500’));
          This doesn’t work.
          I have tryed to do this in many ways, and I think that getResources don’t work for TV’s value. Any ideas why?
          you can also use directly the @SELECT binding instead of running a query by a snippet
          It is better to call a snippet because even that small piece of code isn’t looking good in a single-line and without any highlights of code.
          BTW, if you’re using getResources, you can set the last tpl to be without the ’||’ delimiter.
          Thanks for hint but I already knew that.
            • 11076
            • 159 Posts
            Sorry, I’ve replied to this topic when i was tired & just before going to sleep.

            I had @EVAL working with getResources once...
            i think maybe you should try to specify the context of your resources e.g. ’web’, hope it should do.
            calling getResources in your custom snippet isn’t a bad idea at all, it’s more neat, i just mentioned a shortcut(:
              Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...