We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3866 ☆ A M B ☆
    • 350 Posts
    Hi, I’ve recently completed a new site which when I have the following plugin running will not validate via W3C it throws up a 500 Internal Error message, however, with the plugin disabled it validates fine - could anyone help to see what the problem might be?

    window.addEvent(’domready’, function() {

    //create our Accordion instance
    var myAccordion = new Accordion($(’accordion’), ’h3.toggler’, ’div.element’, {
    opacity: false,
    onActive: function(toggler, element){
    toggler.setStyle(’color’, ’#41464D’);
    },
    onBackground: function(toggler, element){
    toggler.setStyle(’color’, ’#528CE0’);
    }
    });
    });


    The DTD is strict. Help would be appreciated. I have looked at logs and this is the message that that throws up:

    syntax error, unexpected T_FUNCTION


    Parse error: syntax error, unexpected T_FUNCTION in /home/braylake/public_html/manager/includes/document.parser.class.inc.php(746) : eval()’d code on line 1

      Helen Warner
      Number one pixel!
      Proud to be linked with MODX at Crimson Pixel
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Looks like you have javascript code in a plugin. A plugin is PHP code. Or are you talking about a snippet ( [[SnippetName]] )? In either case, it’s PHP code and you’ll need to encapsulate your javascript in PHP and either echo it or return it in the snippet code. Or, depending on where you want it placed in your page, load it into a variable (either a simple variable declaration or HEREDOC syntax) and use the API function $modx->regClientStartupScript($script) to put it in the head or $modx->regClientScript($script) to put it at the end of the body.

      You could also put the raw javascript in a chunk if you just want to insert it into the HTML somewhere.
        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
        • 3866 ☆ A M B ☆
        • 350 Posts
        Ah, that would make sense - it was a while ago since I worked on that aspect of the site. I have actually got it as a javascript file else where - can’t remember now why I was making it a plugin. But will remember that for future.

        Have now disabled the plugin, the toggle still works fine and my site validate.

        Thanks for speedy reply.

        Helen
          Helen Warner
          Number one pixel!
          Proud to be linked with MODX at Crimson Pixel