We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26435
    • 1,193 Posts
    In my template I have the WebLogin snippet displayed in the sidebar, visible on each page. the snippet has been giving me loads of trouble trying to validate my site as XHTML 1.1. Specifically, it is the JavaScript used to "switch" screens within the snippet. The W3C validator issues multiple warnings about the use of the ampersand ("&"), as it is not allowed outside the context of an html entity (" & "). Luckily, my fix was an easy one, and I thought I would share it in case anyone else ran into the same problem. there is a file in assets/snippets/weblogin/ called weblogin.inc.php . This is the file that contains the JavaScript. I copied/pasted the JavaScript into a new file called "weblogin.js", then in "weblogin.inc.php" I used $modx->regClientStartupScript to load a src call to the .js file into the head of the template. I have attached both files in a zip. Upload them to the assets/snippets/weblogin directory of your MODx installation and overwrite the existing weblogin.inc.php (or better yet, rename the original to something clever like weblogin.original.inc.php so you can revert if this f’s up your site).

    -sD-
      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
      All of the above... in no specific order.


      I send pointless little messages
      • 4295
      • 98 Posts
      Scotty, the WebLogin was the only thing preventing me from XHTML Transitional validation. After using your ’patch’ it now validates. But now, the ’forget your password’ link no longer works. It doesn’t display the webLoginShowForm(2) and appears to do nothing. I saved my original weblogin.inc.php file -- so I can go back to that if I have to -- but do you have any idea why this would no longer work when using your patch? Thanks.

      SOLVED: Refreshing the browser or site didn’t seem to work -- but clicking on the register link seemed to clear out and now it works. Thanks a bunch for this patch, Scotty. Ah, sweet validation.
      • Sounds like the .js file isn’t getting loaded. Check your "view source" on the page, and see if the <script...> is getting loaded to include it in the head.

        I always just added "cdata" tags in the script tags to solve this, it was a lot easier.

        http://www.codehouse.com/javascript/tips/xhtml/
          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
          • 4295
          • 98 Posts
          Quote from: sottwell at Sep 21, 2006, 06:16 PM

          Sounds like the .js file isn’t getting loaded. Check your "view source" on the page, and see if the <script...> is getting loaded to include it in the head.

          I always just added "cdata" tags in the script tags to solve this, it was a lot easier.

          http://www.codehouse.com/javascript/tips/xhtml/

          Wow, I switched back to the original weblogin.inc.php file and simply outlined each js with "//<![CDATA[" and "//]]>" and it validates perfectly. This is less complicated than external js files and should be standard practice for <script> blocks. Thanks so much for this great tip -- especially good for programming noobs like me to know.
            • 6726
            • 7,075 Posts
            Very cool tip Susan, and thanks for sharing this XHTML version Scotty, this will come up handy smiley
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
            • Actually, I much prefer external .js files for "unobtrusive javascript", but in the current release the clientStartupScript bit doesn’t work very well.

              http://onlinetools.org/articles/unobtrusivejavascript/
                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
                • 36549
                • 572 Posts
                Hi,

                I have this problem with the WebLogin ampersands "&"...but where do i add the //<![CDATA[ huh?

                Thanks for any help

                J
                  www.9thwave.co.uk
                     WEB | DESIGN | PRINT
                  • 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