We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18654
    • 191 Posts
    The code below was working in Revo Beta 3, but now its returning an empty result set. Any ideas?

    <?php
    	$parent = $modx->resource->get('id');
    	$criteria = $modx->newQuery('modResource', array(
    		'published' => '1'
    		,'deleted' => '0'
    		,'context_key' => 'web'
    		,'parent' => $parent
    		,'class_key' => 'modStaticResource'
    	));
    	$criteria->innerJoin('modTemplateVarResource', 'modTemplateVarResource');
    	$criteria->where(array(
    		"modTemplateVarResource.value LIKE '%Featured%'"
    	));
    	$criteria->sortby('pagetitle','ASC');
    	$criteria->limit(16,0);
    	$numItems = $modx->getCount('modResource', $criteria);
    	$staticResources = $modx->getCollection('modResource', $criteria);  
    ?>
    


    Basically, I’m trying to select a group of objects that have a certain value in a specific template variable. I know that one way to do this would be to just get all objects that are related to the parent and then check each one as I loop through them, but it seems like it would be more efficient to limit the result set up front.

    -matt
      God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
      • 28215
      • 4,149 Posts
      Quote from: mattcdavis1 at Oct 26, 2009, 05:41 AM

      The code below was working in Revo Beta 3, but now its returning an empty result set. Any ideas?
      The aliases have changed since beta4 - we standardized them to make for easier development post-beta. The part that needs to change:

      	$criteria->innerJoin('modTemplateVarResource', 'TemplateVarResources');
      	$criteria->where(array(
      		"TemplateVarResources.value LIKE '%Featured%'"
      	));
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 18654
        • 191 Posts
        Thanks! I spent about 4 hours trying to figure that out. I tried just about every combination of classes except that. Appreciate the help!
          God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.