-1

I use pdoTools and I need to assign one resource to many parents, but physically it'll be in one parent category. What I already did:

Created a new TV "listParents", and in Input Options @eval return $modx->runSnippet('listParents');

Created snippet "listParents"

<?php
$criteria = $modx->newQuery('modResource');
$criteria->where(array(
    'published' => 1,
    'deleted' => 0,
    'isfolder' => 1,
    'template' => 6,
    array('AND:id:!=' => 6)
));
$criteria->sortby('menuindex', 'ASC');
$collection = $modx->getCollection('modResource', $criteria);
$output = array();

foreach ($collection as $v) {
    $output[] = !empty($v->get('menutitle')) ? $v->get('menutitle') : $v->get('pagetitle') . '==' . $v->get('id');
}

return implode('||', $output);

Now I can see all categories in resources: http://prntscr.com/gbq34i and can mark in which categories it should output too besides parent category http://prntscr.com/gbq9y3.

And if I want to go to one of checked categories, I should see this resource. But how can I output it via pdoTools?

1 Answers1

0

I was needed to add small check:

if($isHideInMenu == '1' AND $modx->resource->get("id") != '1') {
  $params['tvFilters'] = 'listParents==%' . $modx->resource->get("id") . '%';
}

The key is this line: $params['tvFilters'] = 'listParents==%' . $modx->resource->get("id") . '%';

It'll find all rows with id of current page, which stores in listParents.