We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10449
    • 956 Posts
    Is there a method or tool to generate the entire site-tree (as seen in the modx-manager) as XML for the frontend?

    I tried using Ditto and Wayfinder. Also custom snippets with $modx->runSnippet() and some help from snippets like getField or hasChildren, but none of these really worked.

    I want to nest each level (subfolder) exactly as seen in the manager-tree.

    Ditto doesn’t do nesting.
    Wayfinder does, but I can’t seem to configure the various tpl chunks to get what I want (i.e. get rid of <ul>s and <li>s etc.)

    Basic example of such a generated XML:

    <menu>
    
    	<item name="MAIN CATEGORY 1" action="1" page="0">
    		<sub name="SUB CATEGORY 1" action="2" page="0">
    			<subsub name="SUB-SUB CATEGORY 1" action="3" page="0" />
    			<subsub name="SUB-SUB CATEGORY 2" action="4" page="0" />
    			<subsub name="SUB-SUB CATEGORY 3" action="5" page="0" />
    		</sub>
    	</item>
    
    	<item name="CONTACT" action="53" page="0" />
    
    </menu>



    node-name: item, sub or subsub = TV value (radio button)
    attributes name, action and page are just TV values


    Is there something I’m missing? A special snippet, method...? This XML is supposed to power a Flash site, in case you wondered.
    It would be trivial to output this for only one folder, but not for a 3-level deep structure with well over 100 items.

    I got quite far with a custom snippet using $modx->runSnippet + Ditto, but the nesting is a hassle and it gets quite chaotic.

    Does anyone know how the actual modx site-tree in the manager is built?
      • 10449
      • 956 Posts
      Well, well... solved it this week. Doesn’t look pretty, but it works :-]