We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34193
    • 330 Posts
    EDIT: See Reply #27 for a working example - still a lot of work to go but the basics are there

    Has anyone used facebook connect on a modx based site. Have been asked by a friend to set up a site for a local rugby club where the players all have face book accounts and he wants me to look into integrating the two. Have never used facebook connect before so still looking into just what it could be used for, then will be looking at how to integrate into modx site.

    Any help would be appreciated, even ideas as to how you have used facebook connect before on either modx or non-modx sites. and how if any integration with modx is.
    • I haven’t done it yet, but one upcoming contract might have me involved in this. Here are a couple links (which you probably already have seen, but they’re relevant to the thread):

      Overview: http://developers.facebook.com/connect.php
      Documentation: http://wiki.developers.facebook.com/index.php/Facebook_Connect
      Example of it in Action (click the "Facebook Connect" button): http://www.somethingtoputhere.com/therunaround/

      Mmm... if someone does crack this nut, they could post the MODx extension in the Facebook Plugin directory:
      http://wiki.developers.facebook.com/index.php/Facebook_Connect_Plugin_Directory

      At least you can look at how other CMS’s integrated... that might be useful.
        • 34193
        • 330 Posts
        ok begining to look at how to code this in modx  will post here as I move forward.  The first step is to create a document with a blank template and alias of xd_receiver.htm and richtext set to off.  This needs the following code taken from the facebook connect documentation.
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
        <html xmlns="http://www.w3.org/1999/xhtml" > 
        <body> 
        <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script> 
        </body> 
        </html> 
        

        My next job is to write a plugin to insert the javascript in at the correct points of the page.
          • 34193
          • 330 Posts
          Step 2.
          First of all make sure that your template contains the following just below your <!DOCTYPE................> declearation
          <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">


          now create a plugin with the following code
          $e = $modx->Event; 
          
          $startscript = '<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> ';
          $endscript='<script type="text/javascript"> FB.init("'.$account.'","xd_receiver.htm"); </script> ';
          
          switch ($e->name) {
                     case "OnWebPagePrerender":
                          $o = &$modx->documentOutput; // get a reference of the output
                          $o = str_replace("<body>","<body>".$startscript,$o);
                          $o = str_replace("</body>",$endscript."</body>",$o);
                           break;
                     default :
                          return; // stop here - this is very important.
                          break;
          } 


          Then click on configuration tab of the plugin and paste the following into the plug in configuration box.

          &account=Account;string;
          


          then enter your facebook app api into the paramiter value box - if you have not generated a facebook app follow the instructions on http://wiki.developers.facebook.com/index.php/Trying_Out_Facebook_Connect

          now click on the system events tab and select OnWebPagePrerender.

          next paste the following code into your site where you want the FBConnect button to appear.
          <fb:login-button></fb:login-button> 


          this will put the button on the page but not much else at the moment.
          • Great work! Be sure to post this on the Wiki!
            http://wiki.modxcms.com/index.php/Main_Page
              • 20413
              • 2,877 Posts
              Thanks for sharing your work!! cool
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 34193
                • 330 Posts
                Quote from: Everett at Jan 26, 2009, 11:28 PM

                Great work! Be sure to post this on the Wiki!
                http://wiki.modxcms.com/index.php/Main_Page


                Once I’ve finished working on it I will post a full tutorial on the wiki I am working on integrating it with web user accounts. So that users can sign in with both Facebook and standard user account.
                  • 30223
                  • 1,010 Posts
                  Before posting anything to the wiki I’d try out a few different ways of solving this first. What I see so far can easily be done with a dedicated template and a snippet instead of a plugin.
                    • 34193
                    • 330 Posts
                    Quote from: TobyL at Jan 27, 2009, 11:52 AM

                    Before posting anything to the wiki I’d try out a few different ways of solving this first. What I see so far can easily be done with a dedicated template and a snippet instead of a plugin.

                    I agree with that and infact when I started looking at it, I got it up and running that very way.  My main reason for moving it to a plugin was incase there people where using multiple templates and wanted to use across all templates the plugin would avoid having to add the code to every template.  That been said if I am trying to avoid having to add to every template I need to work on adding
                    xmlns:fb="http://www.facebook.com/2008/fbml"
                    from within the plugin. Just didn’t have time to figure out how since i don’t think a simple replace will work since the rest of the <html tag could be different for different users.

                    All pointers are greatfully appreciated since this is the first time I have had to develop somthing for use in MODx every other site I have used MODx for I have used exsiting snippits/plugins and just design my own templates and a small amount of modification to bits.  That is the main reason for adding it to the forum has I go along, then the rest of the community can comment and make suggestions.

                    Any how look forward to other suggestions and I am happy to switch it to a dedicated template and snippets if people believe that is the way to go with it.
                      • 10792
                      • 13 Posts
                      Quote from: peteedley at Jan 27, 2009, 08:19 AM

                      Once I’ve finished working on it I will post a full tutorial on the wiki I am working on integrating it with web user accounts. So that users can sign in with both Facebook and standard user account.

                      Thanks, thanks, thanks! Your Work is appreciated smiley
                      Gianfra (from Italy)