We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3719
    • 13 Posts
    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
      • 18373 ☆ 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.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.