-
- 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.
-
- 24,544 Posts
GetMany() is for getting related object via their aliases. Try this:
$accessGroups = $staticResource->getMany('ResourceGroupResources');
-
- 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.
-
- 24,544 Posts
Glad you got it working.
-
- 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
-
- 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
-
- 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.