We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Might &innerHereTpl and &hereTpl be able to work for you?
      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
      • 5689
      • 289 Posts
      &hereTpl works for items like Home where it is the active document itself, but it doesn’t work for items like About Us because About Us is not the current document; one of its children are.

      &innerHereTpl does work because, according to the documentation, it specifies "the template chunk for the current document if in a subfolder". About Us is not in a subfolder. &activeParentRowTpl is exactly what I need to accomplish what I’m doing except that with my two separate menus, the main menu items are at the bottommost level for that menu, so it Wayfinder doesn’t treat them like active parents with &activeParentRowTpl. That’s why modifying the code to apply the &activeParentRowTpl template to items of the same level as the &level parameter works.

      I think this is just becoming more confusing for everybody, but I seem to have figured out what’s wrong, so I think I can find a way to make it work for me. Thanks for all the suggestions, though, and I’ll post again if I come up with a solution that might be helpful to others. laugh
        I'm learning more about MODx all the time and loving it.
        • 20413
        • 2,877 Posts
        I think you need to hack the wayfinder snippet, if you can’t just use empty <a>?
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 5689
          • 289 Posts
          mrhaw, I’d possibly be open to using empty a tags, but even doing that would require different templates, I think. I can’t think of anyway to specify a different class that removes the href attribute. :\ And then there are issues of making the mouse pointer not turn into a hand like it does for links, etc. It’s easier to use separate templates and use my span tags like I want.

          I think I’m just going to add another parameter to my Wayfinder snippet to do what I need. It won’t be that difficult; I’ve looked at the code and it’s well commented and makes sense.
            I&#39;m learning more about MODx all the time and loving it.
            • 20413
            • 2,877 Posts
            Ok, I got myself into this...

            [+wf.classes+] is where your class is added nomatter if <a> or <span>?

            So why not use  <span [+wf.classes+] id="HELLO">[+wf.linktext+]</span>[+wf.wrapper+]

            ?
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 5689
              • 289 Posts
              Because Wayfinder isn’t even assigning the template that contains the span tag. Right now, it doesn’t what the span’s id or classes are. What matters is getting Wayfinder to even assign the template that contains the span rather than the standard a tag one.
                I&#39;m learning more about MODx all the time and loving it.
                • 5689
                • 289 Posts
                Okay, sorry for another double post, but I have fixed the Wayfinder code is a very simple, but effective way that I believe is the way it should be in the first place.

                Let me give a brief explanation before I post the code. In the PHP code, Wayfinder cycles through every document that will be represented on the menu, and for each one, it uses a series of if...elseif...elseif... etc statements to check to see if a certain type of template (such has hereTpl) should apply to the document’s menu item.

                Here is the original elseif statement for the activeParentRowTpl template check:
                } elseif ($resource['isfolder'] && $this->_templates['activeParentRowTpl'] && ($resource['level'] < $this->_config['level'] || $this->_config['level'] == 0) && $this->isHere($resource['id'])) {

                This checks to see if the document in question is a folder, checks if activeParentRowTpl is even specified, checks if the document in question is at lower level (higher in hierarchy) than the level specified in the Wayfinder call (if if the level was set to infinite recursion), and checks if the document in question is in the parent tree of the current document.

                In a normal, single menu with top level documents and their children, activeParentRowTpl will be applied correctly because the current child document would be in the menu, and each parent document would be at a lower level number (higher in hierarchy) than the level specified in the Wayfinder call. However, in my situation where the child documents’ menu items are in a separate menu, the activeParentRowTpl is not applied to documents’ menu items who are parents of the current child because the child is not on the same menu, and therefore the level specified in the Wayfinder call doesn’t go all the way down to the child, so the check for a lower level than the specified parameter fails and the template is not applied.

                To make this work properly in all situations, rather than check if a document in question has a lower level than the level parameter, the level needs to be checked against the level of the current child (which is in the other menu in my case). Because the child isn’t included in my main menu, I couldn’t just get the level of the current child. However, what I was able to figure out is that Wayfinder uses a isHere() function the checks if a document in question is the current document or any of its parents, grandparents, etc. Since the elseif statement for the activeParentRowTpl template already checks to make sure the document in question is one of those documents, all I needed to do was remove the code that checked the level of the document and replace it with code to ensure the document in question is not the current document. The result is that the activeParentRowTpl template will always be applied to the parents, grandparents, etc of any current document, no matter if the current document is in the same menu. Here is my updated elseif statement:
                } elseif ($resource['isfolder'] && $this->_templates['activeParentRowTpl'] && $resource['id'] != $modx->documentObject['id'] && $this->isHere($resource['id'])) {


                In case I just made that all way more confusing than it needs to be, here’s what I did in simple terms. When considering applying the activeParentRowTpl template to a document in the menu, I told Wayfinder to determine is the document is a parent, grandparent, etc of the current document even if the current document does not show up in the same menu. With the original code, the activeParentRowTpl template would only be applied to parent documents of the current document if the current document was in the same menu.

                I hope somebody else can benefit from this, and I’ll see about contacting the author to see if he/she is interested in updating the Wayfinder snippet to use the code I have discussed here.

                Thanks for the suggestions and help, everybody. laugh I’m considering this problem solved.
                  I&#39;m learning more about MODx all the time and loving it.
                  • 25663 MODX Staff
                  • 12,272 Posts
                  The menu you describe is very similar to what we have on the main MODx site and we use the standard Wayfinder port for Revo.

                  Top Menu call:
                  [[Wayfinder?
                      &startId=`0`
                      &level=`1`
                      &sortBy=`menuindex`
                      &textOfLinks=`pagetitle`
                  
                      &outerTpl=`header_whitenav_outerTpl`
                      &rowTpl=`header_whitenav_rowTpl`
                  
                      &hereClass=`current`
                  ]]
                  


                  Side menu call:
                  [[Wayfinder? 
                      &startId=`[[*navbarmenuparent]]`
                      &level=`2`
                      &ignoreHidden=`0`
                      &displayStart=`1`
                      &hideSubMenus=`1`
                  
                      &selfClass=`current`
                      &hereClass=`active`
                      &firstClass=`start`
                  
                      &outerTpl=`leftnav_outerTpl`
                      &innerTpl=`leftnav_innerTpl`
                      &startItemTpl=`wayfinder_startItemTpl` 
                  ]]
                  


                  Doesn’t that accomplish the same thing without hacking up the code?
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 16183
                    • 1,390 Posts
                    @Ryan - the difference is that for instance (on the main MODx site), if one clicks on the main menu item, say, "community" and then clicks on the side menu item on the left "Spread Modx", the "community" item, whilst still having the "active" class applied to it since its child is active/currently being viewed, is still clickable. Compeek at this point would want "community" NOT TO BE clickable. Obviously a "class" parameter cannot help in such situations and so a template parameter is needed. Now,  the obvious one that comes to mind is activeParentRowTpl. However, this template (and probably all the template parameters) is not applied ACROSS menus. This means, it will not be applied in this case since "community" and "Spread Modx" are being called using different WF calls.

                    @Compeek

                    Your suggestion for cross-menu application of the template parameter activeParentRowTpl sounds interesting and may be useful in some cases. However, I think there are still cases where one would not want this cross-application of activeParentRowTpl. Is it therefore better for it to be suggested as a new parameter or similar? Just thinking out loud here..

                    cheers/k
                      • 5689
                      • 289 Posts
                      kongondo, thanks for providing that explanation as to what I’m doing compared to, for example, the MODx site. The was much more clear than the explanations I’ve been trying to give. laugh

                      I agree with what you said about it being a new parameter of some type because, yeah, there will definitely be situations where people will not want this effect. I emailed Kyle Jaebke (one of the two authors) with an explanation of what I did and a suggestion that he use my modification if he agrees with it, so we’ll see what he says. He’ll probably have a better idea of how to possibly add it as a new parameter since he wrote the thing in the first place. smiley
                        I&#39;m learning more about MODx all the time and loving it.