Community

Solved: Exclude collections children from PdoMenu

Is it possible to exclude all children of a collections page in pdomenu?
Tnx Rdg

You should be able to put that exclusion in a &where property, like this (where 12 is the ID of the collections parent folder):

&where=`{"parent:!=":12}`

hi,
well the catch is i don’t know on which ids a collection starts
so something like

&where={"parent-classkey:!=":collection}
or
&where={"parent-template:!=":12}

woiuld be but that doesn’t work

You could look at one of the collections children in the DB with PhpMyAdmin (modx_site_content table). The parent’s ID should be in the ‘parent’ field.

Well the thing is that i need to generate the menu for the whole site and i’ll never know where an editor deside to place a ‘collections’ resource. So i want to tell PDOmenu to stop rendering the menu branch when it hits a collection. Render the collection page. but NOT its children. Looks like i’ll have to write a custom snippet to do that… brrr. :wink:
RDG

That, or train the users. :wink:

Another way might be a plugin that emails you the ID when a user saves a collections folder, so you can add it to the &where property.

Yet another way would be a utility snippet that finds collections folders, and generates and returns the where statement:

&where=`[[!GetCollectionsSnippet]]`

I think that would work if pdoMenu were also called uncached, but I’m not sure.

That is actualy a good idea! i’ll give it a try

Hi,
I tried this but it wont work.
I have a snippet that returns
{"parent:NOT IN":"array(4,6,64)"}

$o = '';
$docs = $modx->getCollection('modResource',array('class_key'=>'CollectionContainer'));
if($docs){
    $o = '{"parent:NOT IN":"array(';
    foreach ($docs  as $doc){
        $o .= $doc->get('id') .',';
    }
    $o= substr($o, 0, -1);
    $o .=  ')"}';
}
return $o;

I tested this and it works and i put that in the PDOmenu call
[[!pdoMenu?
&parents=0
&level=10
&hereId=[[*id]]
&tpl=mobilemenu-tpl
&tplOuter=mobilemenu-outertpl
&where = [[!getMenuAttributes]]
]]

now the menu stays totally empty.
is the where statement ok like this?

tnx RDG

The value should have backticks around it, but maybe the forum is removing them.

I think the value you want for &where is:

`{"width:NOT IN":[4,6,64]}`

So something like this:

$o = '';
$ids = array();
$docs = $modx->getCollection('modResource',array('class_key'=>'CollectionContainer'));
if($docs){
    foreach ($docs  as $doc){
        $ids[] = $doc->get('id');
    }

   $arrayString = implode(',' , $ids);
    $o =  '{"parent:NOT IN":[' . $arrayString . ']}'
} else {
    $modx->log(modX::LOG_LEVEL_ERROR, 'No Docs found');
}
return $o;

Yeahhh, this works it was the array notation that did it.
Tnx a lot!

I’m glad I could help. :slight_smile: