Skip to content

Instantly share code, notes, and snippets.

@OlegShchavelev
Created November 16, 2019 11:29
Show Gist options
  • Save OlegShchavelev/63f4623b74c877ae3ce9d677fd801e5d to your computer and use it in GitHub Desktop.
Save OlegShchavelev/63f4623b74c877ae3ce9d677fd801e5d to your computer and use it in GitHub Desktop.
Вывод мультикатегорий в MS2
$id = $modx->resource->id;
$tpl = '@INLINE <a href="[[~[[+id]]]]">[[+pagetitle]]</a>';
$pdo = $modx->getService('pdoFetch');
$options = array(
'innerJoin' => array(
'msCategory' => array('on' => 'msCategoryMember.category_id = msCategory.id')
),
'select' => array('msCategory' => 'all'),
'sortby' => 'msCategory.id'
);
$conditions = array('product_id' => $id);
$rows = $pdo->getCollection('msCategoryMember', $conditions, $options);
$output = '';
foreach ($rows as $row) {
$output .= $pdo->getChunk($tpl, $row);
}
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment