We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40572
    • 10 Posts
    hey,

    im trying to get a query WITH the related TV's but i have no idea any more after thousands of trys..

    I have a TV with Name: Presentation Time

    and i want to sort my Ressources by this TV is this possible?

    My Try:

    $c = $modx -> newQuery('modResource');
    
    $c -> where(array('parent:IN' => array($parent_ressource), 'deleted' => false, 'hidemenu' => false, 'published' => true, ));
    
    $c->sortby('Presentation Time','ASC');
    
    $resources = $modx -> getCollection('modResource', $c);


    But it comes up following message

    Notice: Undefined variable: locations in C:\xampp\htdocs\modx\core\cache\includes\elements\modsnippet\18.include.cache.php on line 32
    
    Warning: array_unique() expects parameter 1 to be array, null given in C:\xampp\htdocs\modx\core\cache\includes\elements\modsnippet\18.include.cache.php on line 32
    
    Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\modx\core\cache\includes\elements\modsnippet\18.include.cache.php on line 36
    
    Notice: Undefined variable: rest in C:\xampp\htdocs\modx\core\cache\includes\elements\modsnippet\18.include.cache.php on line 61


    and this looks like the TV's are not in this Query included, right? I just can get the values of them by getTVValue and this works. But is it possible to integrate the TV's in the Query to Sort by them?

    regards

    Lucas
      • 4172
      • 5,888 Posts
      see how getResources does this.

      this function, used by migx, prepares the condition for sorting by a TV:
      https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1039
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!