We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27449
    • 211 Posts
    Hello,
    I have some problem with the install of the PhpFreeChat snippet.
    I have this code in my PhpFreeChat snippet:

    global $modx;
    $snipPath = $modx->config["base_path"]."assets/snippets/";
    $path = $modx->config["base_path"];
    include_once($snipPath . "/phpfreechat/src/phpfreechat.class.php");

    $params = array();
    $params["client_script_path"]=$path;
    $params["nick"] = ($modx->getLoginUserID()) ? $modx->getLoginUserName() : "guest".rand(1,10); // setup the intitial nickname
    $params["clock"] = false; // true by default
    $params["showwhosonline"] = false; // true by default
    $params["showsmileys"] = false; // true by default
    $params["title"] = "My Chat";
    $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
    $chat = new phpFreeChat( $params );
    $js = $chat->printJavascript(1);
    $st = $chat->printStyle(1);
    $ch = $chat->printChat(1);
    return $js.$st.$ch;


    $chat = new phpFreeChat( $params );

    // register chat javascript and css
    $modx->regClientStartupScript($chat->printJavascript());
    $modx->regClientCSS($chat->printStyle());

    return $chat->printChat();

    -> The expecific problem it is when I execute the snippet, the chat doesn’t work, only show one square with the message "Chat loading...Please wait", like the attached file
      • 26903
      • 1,336 Posts
      Well, the phpFreeChat snippet from the download on the resources section looks like this :-
      global $modx;
      $snipPath = $modx->config["base_path"]."assets/snippets/";
      include_once($snipPath . "/phpfreechat/src/phpfreechat.class.php");
      
      // You can configure PHP Free Chat by setting variables below. See the PHP Free Chat 
      // documentation for options.
      
      $params = array();
      $params["title"] = "Chat Room";
      $params["refresh_delay"] = 2000; // 2000ms = 2s
      $params["nick"] = "guest".rand(1,1000);  // setup the intitial nickname
      $params["isadmin"] = true; // just for debug ;)
      $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
      $chat = new phpFreeChat( $params );
      
      // register chat javascript and css
      $modx->regClientStartupScript($chat->printJavascript());
      $modx->regClientCSS($chat->printStyle());
      
      return $chat->printChat();
      


      Which is not what you’ve got above, you seem to have a return in the middle and instantiate the class twice
        Use MODx, or the cat gets it!
        • 27449
        • 211 Posts
        I replaced the code of the snnipet, but continue with the same problem
          • 26903
          • 1,336 Posts
          OK, this sort of puts you in the phpFreeChat world, are you using the latest version? Maybe ask on the phpFreeChat support thread..
            Use MODx, or the cat gets it!
            • 27449
            • 211 Posts
            Hello,
            I did the test the phpfreechat in the outside of the modx and work well, but when I execute the phpfreechat in the modx I have an javascript error and don’t work.
            You can help me?
              • 26903
              • 1,336 Posts
              OK, what is the javascript error you are getting? I’m no javascript kid but if you post the error someone may be able to help you here.
                Use MODx, or the cat gets it!
                • 27449
                • 211 Posts
                The error it’s on the attached file
                  • 27449
                  • 211 Posts
                  Hello,
                  I had analise the code and I see that when I execute the PHPfreechat on the modx the source it’s diferent when I execute on the static html
                  When I execute the phpfreechat on the modx I have more this code:

                  <!-- Start QuickEdit headers -->
                  <script type="text/javascript" src="manager/media/script/mootools/mootools.js"></script>
                  <script type="text/javascript" src="assets/modules/quick_edit/javascript/QuickEdit.js"></script>
                  <link type="text/css" rel="stylesheet" href="assets/modules/quick_edit/styles/toolbar.css" />
                  <script type="text/javascript">
                  Window.addEvent(’load’,function() {
                  qe = new QuickEdit(2,64,’/modx-OPRC/manager/’,’assets/modules/quick_edit’,$(’QE_Toolbar’));
                  });
                  </script>
                  <!-- End QuickEdit headers -->

                  </head>
                  <body>
                  <!-- Start QuickEdit toolbar -->
                  <div id="QE_Toolbar">
                  <h1>QuickEdit</h1>
                  <ul>
                  <li>Content
                  <ul>
                  <li><a href="#" onclick="qe.open(’content’);return false;" title="Edit Document content">Document content</a></li><li><a href="#" onclick="qe.open(’description’);return false;" title="Edit You can enter an optional description of the document here.">Description</a></li><li><a href="#" onclick="qe.open(’introtext’);return false;" title="Edit Type a brief summary of the document">Summary (introtext)</a></li><li><a href="#" onclick="qe.open(’longtitle’);return false;" title="Edit Here you can enter a longer title for your document. This is handy for search engines, and might be more descriptive for your document.">Long title</a></li><li><a href="#" onclick="qe.open(’pagetitle’);return false;" title="Edit Type the name/ title of the document here. Try to avoid using backslashes in the name!">Title</a></li>
                  </ul>
                  </li> <li>Settings
                  <ul>
                  <li><a id="QE_ShowLinks" class="checkbox" href="javascript:qe.toggleLinks();">Show links</a></li><li><a href="#" onclick="qe.open(’alias’);return false;" title="Edit Here you can select an alias for this document. This will make the document accessible using:\n\nhttp://yourserver/alias\n\nThis only works if you’re using friendly URLs.">Document’s alias</a></li><li><a class="checkbox" href="#" onclick="qe.ajaxSave(’cacheable’, ’cacheable’, ’1’);return false;" title="Edit Leaving this field checked will allow the document to be saved to cache. If your document contains snippets, make sure this field is unchecked.">Cacheable</a></li><li><a class="checkbox" href="#" onclick="qe.ajaxSave(’hidemenu’, ’hidemenu’, ’1’);return false;" title="Edit Select this option to show document inside a web menu. Please note that some Menu Builders might choose to ignore this option.">Show in menu</a></li><li><a href="#" onclick="qe.open(’menuindex’);return false;" title="Edit Menu Index is a field you can use for sorting document in your menu snippet(s). You can also use it for any other purpose in your snippets.">Menu index</a></li><li><a href="#" onclick="qe.open(’menutitle’);return false;" title="Edit Menu title is a field you can use to display a short title for the document inside your menu snippet(s) or modules.">Menu title</a></li><li><a class="checkbox checked" href="#" onclick="qe.ajaxSave(’published’, ’published’, ’’);return false;" title="Edit Check this field to have the document published immediately after saving it.">Published?</a></li><li><a class="checkbox checked" href="#" onclick="qe.ajaxSave(’searchable’, ’searchable’, ’’);return false;" title="Edit Checking this field will allow the document to be searched. You can also use this field for other purposes in your snippets.">Searchable</a></li><li><a href="#" onclick="qe.open(’template’);return false;" title="Edit Here you can select which template the document uses.">Template</a></li>
                  </ul>
                  </li> <li>Go
                  <ul>
                  <li><a id="QE_Manager" href="/modx-OPRC/manager/">Manager</a></li><li><a id="QE_Help" href="http://www.modxcms.com/quickedit.html">Help</a></li><li><a id="QE_Logout" href="index.php?id=64&amp;QuickEdit_logout=logout">Logout</a></li>
                  </ul>
                  </li>
                  </ul>
                  </div>
                  <!-- End QuickEdit toolbar -->



                  How I resolve it?
                    • 4310
                    • 2,310 Posts
                    The QuickEdit code is only added whilst you are logged in as a Manager, so either :
                    1.Disable the QuickEdit Module & Plugin
                    2.Logout of the Manager and check again
                    3.View site in another browser
                      • 27449
                      • 211 Posts
                      I already resolved this problem... but I continue with the error javascript huh

                      The error it is:
                      Line: 138
                      Char: 1
                      Error: Object Expected
                      Code: 0

                      I don’t what is happen... The document where I execute the phpfreechat only have the call snipped of the phpfreechat...
                      How I resolve it?