We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    I’m just hazzling around with DropMenu. After getting the collapsing/expanding stuff done by CSS (and thanks to the great tutorial!) I wonder how I could reproduce my legacy hover-effect. I used the Dropmenu &post parameter to inject the required code:
    <img src="ar_grey.gif" class="passive" /><img src="ar_red.gif" class="active" />
    Dropmenu placed the stuff at the right position, but, due to a special-character issue the code gets cut off just at the first "=" character.
    Are there any escape characters for DropMenu/ModX parameter formatting, like a backslash or something like this?

    Thanks for any advice!
      • 8642
      • 28 Posts
      Quote from: ppaulousek at Jun 17, 2006, 11:59 AM

      Are there any escape characters for DropMenu/ModX parameter formatting, like a backslash or something like this?


      In PHP, if you want to use double quotation marks inside a string that is already surrounded by double quotation marks, you prepend it with a backslash. The same thing applies to single quotations inside strings surrounded by single quotation marks.

      So, replace this: <img src="ar_grey.gif" class="passive" />
      with this: <img src=\"ar_grey.gif\" class=\"passive\" />

      That should do the trick.
        • 34162
        • 1 Posts
        embarrassed Thanks, but I tried this before. But unfortunately it did not do the job. I also put this stuff (escaped) in a chunk and passed this as the parameter.
        The result was always the same:
        <li class="here"><a href="index.php?id=1" title="Introduction to MODx">Home’<img src</a>


        Seems that Dropmenu only accepts plain strings and does no escaping at all.


        • There is a way to pass that kind of thing to snippets, I seem to recall it in connection with the RSS feed snippets. You might want to check the forum for the discussions on them.
            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
            • 8642
            • 28 Posts
            Quote from: ppaulousek at Jun 17, 2006, 01:55 PM

            embarrassed Thanks, but I tried this before. But unfortunately it did not do the job. I also put this stuff (escaped) in a chunk and passed this as the parameter.
            The result was always the same:
            <li class="here"><a href="index.php?id=1" title="Introduction to MODx">Home’<img src</a>


            Seems that Dropmenu only accepts plain strings and does no escaping at all.

            There’s a tick just after "Home" in the code above, that might be a clue. Could you copy and paste the exact way that you’re calling the snippet?
              • 34162
              • 1 Posts
              this is my chunk named "ahover":

              ’<img src\="ar_grey.gif" class\="passive" /><img src\="ar_red.gif" class\="active" />’

              and this is the DropMenu-call:
              [[DropMenu? &post={{ahover}}]]

              and this is the result:
              <li class="here"><a href="index.php?id=1" title="Introduction to MODx">Home’<img src\</a>

              I’m still clueless, maybe I’m using the wrong "backtick"-character? I thought of diving into the Snippet-Code and put "rawurldecode($post)" in the return statement after having rawurlencoded the chunk ....
              • Why do you have your chunk HTML enclosed in single-quotes?
                  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
                  • 34162
                  • 1 Posts
                  Since I use double-quotes within the content. But whatever I enclose the "&post" (or the chunk) in, and even if I don’t enclose it at all: Result is always a string cut off before the first "=" sign: <img src \". Escaping obviously doesn’t work, but I think it should...
                  :’(
                    • 34162
                    • 1 Posts
                    I solved my issue by storing the chunk in rawurlencoded-format
                    %3Cimg%20src%3D%22ar_grey.gif%22%20class%3D%22passive%22%20%2F%3E%3Cimg%20src%3D%22ar_red.gif%22%20class%3D%22active%22%20%2F%3E

                    and by replacing [tt]$post[/tt] in the return-statement of the Dropmenu-source with [tt]rawurldecode($post)[/tt].
                    I guess this is a type of hack, but as far as I can see there should be no drawback, since if no special characters are passed the encoding will return the string unchanged.
                    It simply enhances the scope of parameter-data which can be passed to Dropmenu.

                    Anyway: My html-source now looks as I want it to. wink
                      • 34162
                      • 1 Posts
                      I was wondering why documents inside a folder do not get the $pre and $post data attached, so I looked and
                      found in the DropMenu code (line #250):
                      // it's a document inside a folder
                      else 
                      	{
                      	$itm .= ($child['alias'] > '0' && !$selfAsLink && ($child['id'] == $modx->documentIdentifier)) ? $child[$textOfLinks] : '<a href="[~'.$child['id'].'~]" title="'.$child[$titleOfLinks].'">'.$child[$textOfLinks].'</a>';

                      Adding the $pre and $post strings here fixed it, now all of the menu-items have their pre and post.
                      Strange, though. Why were those parameters omitted?