We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8439
    • 89 Posts
    Some of this betrays relative inexperience with MODx, I’d just like to know what I should have done.

    I have a site design with a number of top level sections, call them A, B, C. Each section may have sub-sections which are to appear in a sub-navigation, call them A1, A2, ... C1, C2

    What I did was produce a separate template for each section, thus templateA, templateB and so on, each page in the section (i.e. folder and contents) use the same template, thus A, A1, A2 etc all use templateA. In section A the Wayfinder call contains &startId=`id of documentA` and in general terms the only difference between some templates is that they differ in the startId value.

    The temptation is to avoid duplication by producing a single template with &startId=`[*parent*]` this would of course mean that the parent document would display the wrong value.

    Obviously I could have different templates for parent and children but this increases the number of templates.

    Is there a way in which I could have a single template which generated a startId of ’me’ if it was a folder/container and generated a startId of ’parent’ if it was inside a folder? That way I could use the same template for different folders with the sub navigation being correct and without editing the startId.

    Ed
    • Create a TV, name it whatever you like, say StartTV. Give your templates access to it. Set its default value to @INHERIT

      Now, for your "parent" documents, change that TV to be the ID of the document. All of its children will inherit the same value. Use the TV as the startId value in the Wayfinder call:

      [[Wayfinder? &startId=`[*StartTV*]` ... ]]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 8439
        • 89 Posts
        Quote from: sottwell at Dec 07, 2006, 11:59 AM

        Create a TV, name it whatever you like, say StartTV. Give your templates access to it. Set its default value to @INHERIT

        Now, for your "parent" documents, change that TV to be the ID of the document. All of its children will inherit the same value. Use the TV as the startId value in the Wayfinder call:

        [[Wayfinder? &startId=`[*StartTV*]` ... ]]

        Yes I know I’m lazy, is there a way to find what ID the document I am just creating will have?

        I assume not as the docId will probably be assigned on first save. It looks like I have to create it, save it, then go back and edit the startTV.