We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38357
    • 178 Posts
    Hello all,
    Using Revo 2.2.8
    I am using a superfish menu and wayfinder and would like the Category menu items at the first menu level to activate the drop-down menu when clicked (mainly for Ipad users). At the moment they activate the menu on hover, but when clicked go to a blank page. Does anyone have a solution to this?

    Thanks

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That'll be in your Javascript. You can have the Category Folder menu items use a special tpl so there's no link, but the Javascript may not like that. The Javascript should disable the default behavior of the click action for those items. There are a number of ways to do that; it depends on what Javascript library you are using.
        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
        • 38357
        • 178 Posts
        Thanks Susan,
        I found a change for the javascript code at http://stackoverflow.com/questions/7312414/superfish-jquery-menu-open-on-click-rather-than-hover
        but it doesn't appear to work for me - perhaps my javascript library isn't the right one? How would I know if this is the case?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I have no idea. There are a number of these floating around, so I have no way of knowing which one you're using.
            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
            • 38357
            • 178 Posts
            Where would I look to find that information?
              • 38357
              • 178 Posts
              Perhaps the solution to my problem is in Wayfinder rather than in the JQuery menu code.
              I have a number of Category menu items, some of which go directly to a page when clicked and others which activate a submenu on hover. However if the ones which activate the submenu are clicked they go to a blank page if set as a document, or a blank folder if they are set as a container.

              Is there some way, perhaps using wayfinder calls, to ensure that if a category menu item is set as a container that it does not react to a click, staying on the current page and displaying the submenu as it does now? I have tried using the link attributes but there appears to be no way of achieving this by that means.

              Thanks for the assistance.


                • 24374
                • 322 Posts
                Quote from: bobd72 at Nov 13, 2013, 08:16 PM
                Perhaps the solution to my problem is in Wayfinder rather than in the JQuery menu code.
                I have a number of Category menu items, some of which go directly to a page when clicked and others which activate a submenu on hover. However if the ones which activate the submenu are clicked they go to a blank page if set as a document, or a blank folder if they are set as a container.

                Is there some way, perhaps using wayfinder calls, to ensure that if a category menu item is set as a container that it does not react to a click, staying on the current page and displaying the submenu as it does now? I have tried using the link attributes but there appears to be no way of achieving this by that means.

                Thanks for the assistance.


                If I'm getting what you're saying, then I wrote a small addon for this very problem. It creates menu links based on the first page down the tree that actually has content in any given menu structure, so if you have a Category menu item that is a folder in the tree, but no content, the link in the menu will get changed to the first document under that folder that has content (or, if the first document is itself a folder, to the first one under that, etc.). So, the menu item Category won't link to itself, but to the first actual page in that section. Please check it out:

                http://modx.com/extras/package/firstpagelink

                There are instructions for how to alter your wayfinder row templates (chunks).


                The other solution is to put, in the header of every page, some code like this:

                // check whether this is a container, and if so load child page
                if(($modx->resource->get('content')=='') {
                $goodpage=$modx->runSnippet('firstPageLink',array('pid'=>$modx->resource->get('id')));
                	if(strlen($goodpage)>1) {
                		header("Location: $goodpage");
                	}
                }
                


                If you don't want to use firstPageLink, then you could change the line of code that references that to code that fetches the first published page that has the current page as its parent. This method doesn't change the links in the menus, but rather makes blank pages redirect to ones that have content.