We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23054
    • 62 Posts
    For the snippet DropMenu I try to change the document root depending on the current document.
    So I wrote a plugin that checks the current document id.

    Anyway - ’OnParseDocument’ does not seem to influence the behavior of the DropMenu snippet because it seems to be parsed before ?

    My idea:

    • create a template variable called ’docRoot’, set it to 0 by default
    • in the template I defined the Dropmenu-generation

      [[DropMenu?&hereClass=`currentPage`&topnavClass=`menuList`&levelLimit=`3`&removeNewLines=`true`&startDoc=`[*docRoot*]`]]

    • create a plugin that shall be triggered by ’OnParseDocument’ and shall change the value of [*docRoot*]

      $id = $modx->documentIdentifier;
      $parentId = $modx->getParent($id,1,’id’);
      $parentId = $parentId[’id’];
      $rootArray = new Array();
      $rootArray[’aendern’] = 57; # folder _Aendern
      $rootArray[’gucken’] = 56; # folder _Gucken

      if ($id==50 || $parentId==50)
      $modx->documentObject[’docRoot’] = $rootArray[’aendern’];
      else
      $modx->documentObject[’docRoot’] = $rootArray[’gucken’];

    But it seems the menu is created before the plugin is called because I can write here whatever I want - it does not do anything ?

    PS:
    I got an idea why that does not work - there is no way to set the template variable dynamically for documents ?
    Therefore $modx->documentObject[’docRoot’] does not work, what a pity sad
      • 15987
      • 786 Posts
      You could try using the ultimateparent snippet along with dropmenu to achieve the same result:

      [!DropMenu?&hereClass=`currentPage`&topnavClass=`menuList`&levelLimit=`3`&removeNewLines=`true`&startDoc=`[!ultimateparent!]`!]


      get it here: http://modxcms.com/UltimateParent-643.html
        • 27226
        • 186 Posts
        I tried to call DropMenu with different startDocs, provided by a - manually edited - TV. And it didn’t work.
        But it did work, when I put the whole DropMenu-Snippet call into the TV. So, if you use a snippet, which generates a TV, containing the complete call with the (dynamic) docroot-param, and not only the latter, I guess it could work...