We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18654
    • 191 Posts
    In the code posted below, it seems like the line that is commented out should be doing the exact same thing as the line below it. But for some reason when I try to use the commented-out line (and remove the line underneath it), it doesn’t work. Any ideas?


    <?php
    	$parent = $modx->resource->get('id');
    	$count = 0;
    	$criteria = $modx->newQuery('modResource', array(
    		'published' => '1'
    		,'deleted' => '0'
    		,'context_key' => 'web'
    		,'parent' => $parent
    		,'class_key' => 'modStaticResource'
    	));
    	
    	$criteria->sortby('pagetitle','ASC');
    	$criteria->limit(16,0);
    	$staticResources = $modx->getCollection('modResource', $criteria);  
    
    	foreach ($staticResources as $staticResource) { 
    		//$accessGroups = staticResource->getMany('modResourceGroupResource'); //can't understand why this line won't work but the line below will
    		$accessGroups = $modx->getCollection('modResourceGroupResource', array('document' => $staticResource->get('id')));
    		foreach ($accessGroups as $ag) 
    			{
    				echo $ag->get('document_group');	
    			}
    		$outputArray['videoRelId'] = 'overlay_' . $staticResource->get('id');
    		$videoPath = ($staticResource->get('content') != '') ? 'assets/media/' . $staticResource->get('content') : 'default.flv';
    		$outputArray['videoPath'] = file_exists($videoPath) ? $videoPath : 'assets/media/video/default.flv';
    		echo $modx->parseChunk('listSelectedVideosOverlay', $outputArray);
    		$count++;
    	} 
    ?>
    

      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.
      • 3749
      • 24,544 Posts
      GetMany() is for getting related object via their aliases. Try this:

      $accessGroups = $staticResource->getMany('ResourceGroupResources'); 
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 18654
        • 191 Posts
        Thanks Bob! - It looks like I had forgotten the ’$’ character before the staticResource variable as well. Appreciate the help - works fine now.
          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.
          • 3749
          • 24,544 Posts
          Glad you got it working. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 28215
            • 4,149 Posts
            Fyi, if you want the relationship aliases, they’re all listed in the core/model/schema/modx.mysql.schema.xml file.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 3749
              • 24,544 Posts
              Quote from: splittingred at Nov 02, 2009, 02:35 AM

              Fyi, if you want the relationship aliases, they’re all listed in the core/model/schema/modx.mysql.schema.xml file.

              Almost all of them are listed here as well (at the bottom of the page) in a friendlier format: http://bobsguides.com/revolution-objects.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 28215
                • 4,149 Posts
                Quote from: BobRay at Nov 02, 2009, 02:45 AM

                Almost all of them are listed here as well (at the bottom of the page) in a friendlier format: http://bobsguides.com/revolution-objects.html

                Oh Bob, how we need to get you Confluence access. tongue Thanks!
                  shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                  • 18654
                  • 191 Posts
                  Quote from: splittingred at Nov 02, 2009, 02:35 AM

                  Fyi, if you want the relationship aliases, they’re all listed in the core/model/schema/modx.mysql.schema.xml file.

                  Yeah, I use that frequently (and Bob’s Guides as well). I was writing the above code at 4am after sitting in front of my monitor for 8 hours and I think I had put the alias in at one point but was still missing the ’$’ character before my variable, so I ended up reverting to the class name thinking the alias was the wrong input when in fact the problem was the missing ’$’ character.
                    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.