Last active
July 15, 2016 07:07
-
-
Save Rachind/cac1a590a38ed94c146b1e2ef9975e8b to your computer and use it in GitHub Desktop.
Snippet resourcesList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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