Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antk25/840ab26ddf3ac8be7abc1cc4b1201bf9 to your computer and use it in GitHub Desktop.
Save antk25/840ab26ddf3ac8be7abc1cc4b1201bf9 to your computer and use it in GitHub Desktop.
Выборка дополнительных категорий и вывод ссылок на них.
<?php
if (empty($id)) {$id = $modx->resource->id;}if (empty($tpl)) {$tpl = '@INLINE <a href="[[~[[+id]]]]">[[+pagetitle]]</a>';}
$pdo = $modx->getService('pdoFetch');
$conditions = array('product_id' => $id);
$options = array(
'innerJoin' => array(
'msCategory' => array('on' => 'msCategoryMember.category_id = msCategory.id')
),
'select' => array('msCategory' => 'all'),
'sortby' => 'msCategory.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