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