We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23260
    • 30 Posts
    I noticed there is a &pre variable for the menu snippet, is it possible to use this to generate unique IDs for each of the menu Items? I have a design that relies on image replacement techniques. Currently, I am using static menus, but I would like to use the DropMenu snippet so that I can rely on the ability to add acurrent class without resorting to writing a custom script.

    Cheers,

    Phil
      • 6726
      • 7,075 Posts
      Funny you mention this, I was starting to look at those pre and post parameters and had the same idea : not tested it yet though...

      I can’t see why it wouldn’t work !
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
      • LOL ... and I was wondering the same exact thing, too... don’t know why not actually, just set to <span id="menu[*id*]"> for &pre and </span> for &post to wrap the A or LI elements with uniquely ID’d tags. If that won’t work, might take a bit of hacking but somehting that could/should be requested in teh bugtracker... quite useful!
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 6726
          • 7,075 Posts
          It’s amazing all those things you can do with the [*id*] passed into the parameter... that’s very nice and I’ll toy with that !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 23260
            • 30 Posts
            Okay cool, I’ll give it a shot. I’d rather not use spans, but I can’t hardly complain. Thanks for the tip!

            Phil
              • 7455
              • 2,204 Posts
              if you only need a 1 level menu take a look at this snipped made by jared:
              ListGlobal
                follow me on twitter: @dimmy01
                • 23260
                • 30 Posts
                Sorry, no go. the following code:

                [[DropMenu? &selfAsLink=`true` &startDoc=`0` &levelLimit=`1` &hereClass=`active` &pre=`` &post=`` ]]
                <br /><br />as a test creates some strange results. First, the pre & post text is rendered [i]inside[/i] the a tag instead of on the outside as it’s supposed to. Secondly, either the double quotes or the = sign (or both?) is causing a rendering issue. This is what the source of the outputed page reveals: <br /><br />
                <li><a href="minimal-base/" title=""><span clasHome></span></a></li>
                <br /><br />Strange. Perhaps something for the bugtracker, or perhaps I missing somthing really obvious here (and making a fool out of myself in the process :-[ )
                  • 6726
                  • 7,075 Posts
                  I did not test it yet, but it might be intentionnal, since this kind of css code allow you to create a dropmenu.

                  See this article of Eric Meyer :
                  http://www.meyerweb.com/eric/css/edge/popups/demo.html

                  This will indicate how to style your spans so that you can have a pure css dropmenu smiley
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 23260
                    • 30 Posts
                    Yes, I’m familiar with that technique and you are probably right. But the behavior that this is producing doesn’t really seem to match-up with that either. If I use an empty span as pre and post it outputs something like:

                    <li><a href="thelink"><span>link title</span></a></li>


                    Using the Eric Meyer technique you just mentioned would simply hide the link text. I’m guessing that providing a MODx var in the pre might solve that problem, to produce something like:

                    <li><a href="thelink">link title<span>link description</span></a></li>


                    Hmmm. Okay, still the problem of = &/or " causing rendering issues (I tried single-quotes too). And in the documentation for the menu snippet:

                    http://www.modxcms.com/snippet-dropmenu.html


                    • &pre [ string ] - Text to append before links inside of LIs. Defaults to ’’ (empty string).
                    • &post [ string ] - Text to append after links inside of LIs. Defaults to ’’ (empty string).

                    ... I would assume mean <li>PRE<a></a>POST</li>
                    ... or even (’inside’ of LIs) <li PRE><a></a></ POST li>

                    huh
                      • 6726
                      • 7,075 Posts
                      OK, I see your point here.

                      We should link to your post in the DropMenu thread, and submit this to the author of the snippet, I guess.
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id