You can do something similar in DokuWiki, but it takes an extra step. Create a page with the code you want to exectute, a standard Dokuwiki page, and place your code into it. Since you want to create a navigation output based on indexmenu, let's say you put your code in :wiki:nav:
{{indexmenu>..#1|navbar}}
Then in your template, at the position where you want your index, you enter the following code:
<?php echo p_wiki_xhtml(':wiki:nav');?>
This will output, at the insertion point, the contents of :wiki:nav, which in the case is your indexmenu.