Skip to content

Instantly share code, notes, and snippets.

@Rachind
Last active July 15, 2016 07:07
Show Gist options
  • Save Rachind/cac1a590a38ed94c146b1e2ef9975e8b to your computer and use it in GitHub Desktop.
Save Rachind/cac1a590a38ed94c146b1e2ef9975e8b to your computer and use it in GitHub Desktop.
Snippet resourcesList
<?php
// сниппет resourcesList
// можно формировать по parent и по template
// в возможных значениях tv: @EVAL return $modx->runSnippet('resourcesList', array('template'=>17));
$q = $modx->newQuery('modResource');
$q->select(array(
'modResource.id as id',
'modResource.pagetitle as pagetitle'
));
$where_arr = array(
'deleted' => 0,
'published' => 1
);
if(!empty($parents)) {
$where_arr['modResource.parent:IN'] = explode(',', $parents);
}
if(!empty($template)) {
$where_arr['modResource.template'] = $template;
}
$q->where($where_arr);
$q->prepare();
$q->stmt->execute();
$result = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
$out = '';
foreach ($result as $v) {
$out .= '||'.$v['pagetitle'].'=='.$v['id'];
}
return $out;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment