Skip to content

Instantly share code, notes, and snippets.

@ideesimple
Forked from rtripault/Input Option Values :
Created November 25, 2010 11:04
Show Gist options
  • Save ideesimple/715214 to your computer and use it in GitHub Desktop.
Save ideesimple/715214 to your computer and use it in GitHub Desktop.
<?php
/* build a query to get Resources with a given parent that are published and not deleted */
$query = $modx->newQuery('modResource', array('parent' => $idRessource, 'deleted' => false, 'published' => true));
/* to optimize, you can select only the columns you need */
// $query->select($modx->getSelectColumns('modResource', 'modResource', '', array('id', 'class_key', 'context_key')));
/* get the modResource objects with the given parent */
$children = $modx->getCollection('modResource', $query);
/* loop through the children and push the id onto $resourceIds */
$resourceIds = "";
$i=0;
foreach ($children as $child) {
if ($i!=0) {
$resourceIds .= "||";
}
$resourceIds .= $child->get('pagetitle');
$resourceIds .= "==";
$resourceIds .= $child->get('id');
$i++;
}
return $resourceIds;
@EVAL return $modx->runSnippet('getAside',array("idRessource" =>"147"));
Don't forget to set Ouput Type as Delimiter «,» in order to be able to use the ouput in a getResources call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment