Skip to content

Instantly share code, notes, and snippets.

@sxidsvit
Last active June 7, 2016 21:15
Show Gist options
  • Select an option

  • Save sxidsvit/45b52b5629d4db34337dcbb49ee9f34b to your computer and use it in GitHub Desktop.

Select an option

Save sxidsvit/45b52b5629d4db34337dcbb49ee9f34b to your computer and use it in GitHub Desktop.
Выборка значений TV-параметра из таблицы MODx (А.Петропавловский)
<?php
$tvid = 9;
$res = array();
$temp = array();
$output = '';
$q = $modx->newQuery('modTemplateVarResource', array('tmplvarid' => $tvid));
$q -> select('contentid, value');
if ($q->prepare() && $q->stmt->execute()) {
while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
$val = explode(',',$row['value']);
$temp = array_merge($temp, $val);
}
}
$result = array_unique($temp);
foreach ($result as $item) {
$output .= '<li><a href="#" class="'.$item.'">'.$item.'</a></li>';
}
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment