We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for <a href="http://modxcms.com/extras/package/682">Facebook Page Share Icon 2.0-stable</a> by wartornskull.

    Brief Description:
    This is a port of the "Facebook Share Link Button" for MODx Evo systems, which is a very simple way of letting users share your pages via facebook.



    Not much changed just updated the MODx tags to work with MODx Revolution, also added alt text to the facebook icon, and set the img border to 0.
      • 31255
      • 118 Posts
      Ok. Put this to chunk and called it in template. When try to share a page, on frontpage everything is ok. But in sub pages url is something odd. starts with: http://http%3A%2F%2F and al slashes are %2F coded too. Tried another snippet (v. 1.0.0)it has same problem.

      Neither it doesn`t read page data right, there`s no page titles and so on. On frontpage everything is ok.

      Using Evo 1.0.5 and friendly urls.
        Tassu, webmaster of Valokammi
        • 31255
        • 118 Posts
        Solved when turned friendly url paths off.

        Is there possible fix for this?
          Tassu, webmaster of Valokammi
          • 33968
          • 863 Posts
          Actually the ’odd characters’ are there because of the way facebook has suggested the share URLs be encoded. I tried to find a link to their developer page for your reference, but since they now prefer everyone to use the ’Like’ button instead they seem to have removed that page undecided

          I’m using my own ’share’ snippet but the functionality is basically the same and it works fine with friendly urls.

          My links look like this:
          http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.sitename.com%2Ffolder%2Fpage

          If you click the link does it work?
            • 31255
            • 118 Posts
            Damn FB!

            Yeah, link is okay.

            So, is your snippet code available anywhere?
              Tassu, webmaster of Valokammi
              • 31255
              • 118 Posts
              Does google find cached pages of that FB thing?
                Tassu, webmaster of Valokammi
                • 33968
                • 863 Posts
                This is what I did (for Evolution). Of course, there might be a better way of doing this but it works for me!

                Create a chunk called shareFacebook or whatever you want to call it, and paste in the following:
                <a href="http://www.facebook.com/sharer.php?u=[[PageUrl?id=`[*id*]`]]&t=[*pagetitle:uri*]" onclick="javascript:window.open('http://www.facebook.com/sharer.php?u=[[PageUrl?id=`[*id*]`]]&t=[*pagetitle:uri*]','','width=700,height=400'); return false">Share</a>


                Create the following snippet:

                PageUrl (gets and encodes the current page url)
                <?php
                $url = urlencode($modx->makeUrl($id, '', '', 'full'));
                return $url;
                ?>


                Now add {{shareFacebook}} wherever you want the share link to appear in your page template.

                You can add a class to the link and style it with an icon if you want.

                Note: facebook is discouraging continued use of the share button as they want people to ’like’ things instead. But ’share’ certainly makes more sense in some instances.
                  • 31255
                  • 118 Posts
                  Now got parsing error. I`ve tried another way, which had same snippet, got same error when using it.

                  Error:
                  `[*id*]` is not numeric and may not be passed to makeUrl()

                  Update: Strange things happen. Now got original script (1.0.0) working with friendly alias paths url. What I did just cleared caches. I might be wrong but I don`t think that`s real solution for url problem. But now it`s working. Thanks for your time.
                    Tassu, webmaster of Valokammi