We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • That probably means something wrong with the snippet. Most likely a bad path for the functions.jsconnect.php file.

    Test the snippet by just having
    return "Hello??";


    Now loading that page should display
    Hello??
      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
      • 18367
      • 834 Posts
      OK,

      no errors showing in the reports

      Bottom line no snippets of any type are getting called on this page. (I tried duplicating the Doc and using other snippets with the same result. Weird.)

      Here's my call
      [[!VanillaSSO]]
      


      Here's my snippet

      <?php
      require_once('http://www.hotbuttonmarketing.com.au/assets/libraries/functions.jsconnect.php');
      $clientID = 'xxx'; // I do have actual numbers here put your client ID here
      $secret = 'xxxx'; // put your secret code here
      
      $user = array();
      if ($modx->user->isAuthenticated('web')) {
      $profile = $modx->user->getOne('Profile');
      $email = $profile ? $profile->get('email') : '';
      $user['uniqueid'] = $modx->user->get('id');
      $user['name'] = $modx->user->get('username');
      $user['email'] = $email;
      }
      
      $secure = true; // false for test only mode - will skip the ID and secret tests
      
      WriteJsConnect($user, $_GET, $clientID, $secret, $secure);


      I've checked the functions file and it is in the directory.

      It is uncached and it has no template (empty)

      When you say resource do you mean Static Resource or Document? And do I have to save it as a particular Content Type?

      PS The hello test worked.

      [ed. note: markg last edited this post 11 years, 6 months ago.]
        Content Creator and Copywriter
      • No, just an ordinary resource. Published. No template (empty). Only a page title, an alias, and the snippet tags in the content. I also have it set to not show in menu.
          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
        • That is NOT a path, it is a URL. Just put
          require_once('assets/libraries/functions.jsconnect.php');


          require, require_once, include, include_once are file streaming directives, they need file paths, not URLs. Things that are loaded by the browser, such as .css or .js files or AJAX calls need URLs so they can request the files via the web server. PHP code is working on the physical server, actually using native C program code in the background (the PHP code is basically just a wrapper to the more complicated C code to make things easier for us developers), so it doesn't make requests to the web server. [ed. note: sottwell last edited this post 11 years, 6 months ago.]
            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
            • 18367
            • 834 Posts
            Arrrgh

            I did have it like that originally, but I changed it to the full url when I was getting no result.

            I changed it back and now at least I', getting an error message:

            {"error":"invalid_request","message":"The client_id parameter is missing."}


            So, progress of sorts.

            PS Vanilla is still not recognising the Modx User.


            [ed. note: markg last edited this post 11 years, 6 months ago.]
              Content Creator and Copywriter
            • That's exactly what you should be getting! The Vanilla AJAX call will provide that parameter when it's being called from Vanilla.
                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
              • Ok, now we know that the snippet works. Now you need to go set up the JSConnect plugin in your Vanilla manager.
                  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
                • You did set up a new user for the web context in MODx, and log in as that user (not in the Manager)?
                    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
                    • 18367
                    • 834 Posts
                    The JSConnect Plugin was already setup, do I need to redo it?

                    And Yes I did set up a new user, I'm testing the user login in a different browser.

                    From your choice of words "web context" does that mean I have to set up a new user group for the forum in modx?
                      Content Creator and Copywriter
                    • Yes. This should be a separate user from your Manager user. I used the basic tutorials in the Login documentation (you can skip the resource group part)

                      http://rtfm.modx.com/display/ADDON/Login.Basic+Setup
                        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