I have checked the documentation but must be missing something really obvious here.
I want to build a single level menu in Revolution (using Wayfinder currently but easily could use getResources if needed) that will display a menu link to the first child of any container. That is, if a resource has children, I want the first child to be the top level menu link.
I know I can use FirstChildRedirect in the container, but how do I get the menu link to be the menu link of the first child?
Bobby
-
☆ A M B ☆
- 3,141 Posts
One way would be to make the top level container a weblink (you can change the class_key to modWebLink on the Settings tab).
Another way would involve writing a snippet that is being called in your rowTpl, like this:
[[linkFirstChild? &parent=`[[+wf.id]]`]]
linkFirstChild code:
$parent = $modx->getOption('parent',$scriptProperties);
if (!is_numeric($parent)) { return; }
$c = $modx->newQuery('modResource');
$c->where(array(
'parent' => $parent,
'published' => 1,
'hidemenu' => 0));
$c->sortby('menuindex',asc);
$c->limit(1);
$fc = $modx->getObject('modResource',$c);
if ($fc != '') {
return '<a href="'.$modx->makeUrl($fc->get('id')).'">'.$fc->get('menutitle').'</a>';
}
Untested but should point you in the right direction.