Running in MODX Revolution 2.1.3-pl.
I'm using a slightly modified version of a script I found here to show or hide pages based on whether or not "yes" or "no" is selected in a TV.
Currently, the snippet is putting out a list of resource ID's that should be shown in the menu.
<?php
/* build a query to get Resources with a TV id of 2 that are published and not deleted */
$query = $modx->newQuery('modTemplateVarResource', array('tmplvarid' => 14, 'value' => 1));
/* to optimize, you can select only the columns you need */
$query->select($modx->getSelectColumns('modTemplateVarResource', 'modTemplateVarResource', '', array('id', 'contentid', 'value')));
/* get the modTemplateVarResource objects with a TV id of 1 */
$children = $modx->getCollection('modResource', $query);
/* loop through the children and push the id onto $resourceIds */
$resourceIds = array();
foreach ($children as $child) {
$resourceIds[] = $child->get('contentid');
}
return implode(',', $resourceIds);
I originally had this working with Wayfinder, but I needed child pages to show even if the parent page was hidden. I think getResources can do that (if it can't, let me know, that's what I was trying to test with this).
The only problem is, even when I return the list of ID's in the resources parameters (as per below), getResources still shows all of the pages on my website. Is there a way to make it only show resources in the parameter, or am I just completely misunderstanding how all of this is coming together?
[[!getResources? &parents=`0` &resources=`[[SidebarShowGetResources]]` &tpl=`sidebarMenuTpl`]]
I appreciate any help.
[ed. note: firebot6 last edited this post 14 years, 11 months ago.]