We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40349
    • 26 Posts
    Hi Everyone,

    First time posting here!

    I have a website that has a horizontal main navigation at the top. What I am trying to do is have the main top navigation with drop downs (which works). The second navigation is going to be Dental Service to show in the right red box down by the content. We want to show all the sub menus under Dental Services.

    My goal is to have one template to call the different interior page menus for the different sections. I figured doing this would require a "if statement", but I can't get it to work. To be honest I am new at Modx and also new with PHP. I have been trying to work this out for 8hrs. I have also tried searching to see if any one had any examples how to do this. I found BobRay had one article. I tried his example, but was completely lost.

    Example of Main Menu:

    Dental Services (2)

    • Fillings(7)
    • Teeth Cleaning(11)
    New Patient(3)

    • New Patient Form(8)
    • Insurance Accepted(9)
    Our Practice(4)

    • Gallery - Office Art(10)
    Directions(6)
    Contact Us(5)

    Here is the example of a if statement that I was working from seeing at BobRay

    <?php
    $current_docid = $modx->resource->get('parent');
    $output ='';

    if($current_docid ==2){
    $output .='[[!Wayfinder? &startId=`2` &level=`1` ]]';
    }

    ?>

    Here is the website that I am working on. http://www.drloperdentist.com/dental-services.html

    You can see that the "Fillings" sub nav is coming in, but if you click on the top main navigation and go to "New Patient" it show that same navition there. At this point it shouldn't show at all.

    I also noticed just above the "Fillings" it has this

    resource->get('parent'); $output =''; if($current_docid ==2){ $output .='
      Wild Eagle Design

      www.wildeagledesign.com
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You could use the UltimateParent snippet to provide the parent ID for the Wayfinder call.
      [[Wayfinder? &startId=`[[!UltimateParent]]` ...]]


      http://modx.com/extras/package/ultimateparent
        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
        • 40349
        • 26 Posts
        Thanks Scottwell. It worked! I also wanted to say thank you for replying to my post so quickly. This has really helped me move on with my day to the next build phase.

        All I did was install the ultimateparent plugin and added
        [[!Wayfinder? &startId=`[[UltimateParent]]` &level=`1` &outerTpl=`sub-nav-outerTpl`]]


        That was so simple. I'm really loving Modx. When I get more experience with it I am going to go back and figure how to did it with the "if statment." Just for learning experience. [ed. note: [email protected] last edited this post 14 years, 3 months ago.]
          Wild Eagle Design

          www.wildeagledesign.com
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Another way to do that is to have a Template Variable (TV) with @INHERIT as its default value, and set the TV value in the parent resource to its own ID. That way all of its children and grandchildren will inherit that value. Then use the TV as the startId value:
          [[Wayfinder? &startId=`[[*myTV]]` ... ]]
            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
            • 40349
            • 26 Posts
            Sottwell,

            I tried to make a TV like you suggested. I named mine "sub-nav." I then went to the TV "sub-nav" and went under the tab "input" and put in the default "@INHERIT".

            For the rest of the TV and I am confused what to do?

            For the template it would look like this.
            [[!Wayfinder? &startId=`[[*sub-nav]]` &level=`1` &outerTpl=`sub-nav-outerTpl`]]
              Wild Eagle Design

              www.wildeagledesign.com
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              In the parent (top-level) resources, edit the TV and put the ID of that resource. For example, if you have a resource #2, "News", edit that resource and put 2 in the TV. Leave the rest of them alone, as the child resources will inherit that value set in the parent. In other words, all the items in the News folder will inherit the value 2 for the TV. Make sure that the Template Variable (when you created it in the first place) is assigned to all the templates used by the parent resource as well as the children.

              The UltimateParent snippet is also a good way. It's just that this is MODx, and there are always several ways to do things.
                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