Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _build/gpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"value": "selectioncontainer",
"namespace": "core"
},
{
"key": "mgr_show_collections_in_grid",
"area": "manager",
"value": ""
},
{
"key": "renderer_image_path",
"area": "manager",
Expand Down
2 changes: 2 additions & 0 deletions core/components/collections/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
$_lang['setting_collections.tree_tbar_collection_desc'] = 'Show "New Collection" button in Tree tool bar';
$_lang['setting_collections.tree_tbar_selection'] = 'Tree Tool Bar - Selection';
$_lang['setting_collections.tree_tbar_selection_desc'] = 'Show "New Selection" button in Tree tool bar';
$_lang['setting_collections.mgr_show_collections_in_grid'] = 'Collection templates displayed in grid';
$_lang['setting_collections.mgr_show_collections_in_grid_desc'] = 'You can specify Collection templates, separated by commas, that will be displayed inside Collection grid.';


// System lexicons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public function run()
}

if ($resource->class_key == CollectionContainer::class) {
$resource->set('show_in_tree', 1);
if (in_array($resource->get('template'), explode(',', $this->modx->getOption('collections.mgr_show_collections_in_grid')))) {
$resource->set('show_in_tree', 0);
} else {
$resource->set('show_in_tree', 1);
}
}

/** @var modResource $original */
Expand Down
21 changes: 17 additions & 4 deletions core/components/collections/src/Processors/Resource/GetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,23 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
break;
}

$c->where([
'class_key:!=' => CollectionContainer::class,
// "NOT EXISTS (SELECT 1 FROM {$this->modx->getTableName('modResource')} r WHERE r.parent = modResource.id)"
]);
$showCollectionsInGrid = explode(',', $this->modx->getOption('collections.mgr_show_collections_in_grid'));
if (!empty($showCollectionsInGrid)) {
$c->where([
'parent' => $parent,
'AND:template:IN' => $showCollectionsInGrid,
'AND:class_key:=' => CollectionContainer::class,
]);
$c->where([
'parent' => $parent,
'AND:class_key:!=' => CollectionContainer::class,
], xPDOQuery::SQL_OR);
} else {
$c->where([
'class_key:!=' => CollectionContainer::class,
// "NOT EXISTS (SELECT 1 FROM {$this->modx->getTableName('modResource')} r WHERE r.parent = modResource.id)"
]);
}

foreach ($this->tvColumns as $column) {
$c->leftJoin(modTemplateVarResource::class, '`TemplateVarResources_' . $column['column'] . '`', '`TemplateVarResources_' . $column['column'] . '`.`contentid` = modResource.id AND `TemplateVarResources_' . $column['column'] . '`.`tmplvarid` = ' . $column['id']);
Expand Down