We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8822
    • 203 Posts
    Hi,
    Does anyone have any advice or ideas on what the best way is to add Facebook Like, Tweet and g+1 buttons to each news story within Articles, such that people can like/tweet/share individual articles/pages and not a generic URL (i.e. www.mydomain.co.uk/news/great-news-story as opposed to www.mydomain.co.uk). The code generated from Facebook developers for example asks for a generic URL, but i want it to be specific to the article, both on the actual article page and in the articles container page, where 10 articles are listed......

    Any ideas? Using Revo
      • 30912
      • 463 Posts
      I found the best way was using Sharethis.com (make sure you read the instructions on there for adding the widgets) and adding the sharecode they generate or similar

      Not tested:

      
      
      <span class='st_twitter_hcount' st_url="[[++site_url]][[~[[+id]]]]" st_title="[[+pagetitle]]" displayText='Tweet'></span>
      <span class='st_facebook_hcount' st_url="[[++site_url]][[~[[+id]]]]" st_title="[[+pagetitle]]" st_summary="[[+introtext]]" displayText='Facebook'></span>
      <span class='st_googleplus_hcount'st_url="[[++site_url]][[~[[+id]]]]" st_title="[[+pagetitle]]" st_summary="[[+introtext]]" displayText='Google +'></span>
      
      


      I think you might need to change ID to Alias, i cant remember offhand

      Hope that helps put you in the right direction.
        • 8822
        • 203 Posts
        Thanks Tyreal2012, thats great and i have used both their component and the code you suggested - works great smiley
          • 8822
          • 203 Posts
          Hi Tyreal, Sorry to come back to this discussion again. We've now gone live, but the code i've used (as per your example above), only works on the Articles Container page (where multiple news items are listed, along with the corresponding social media share buttons), but the same code does not work on the actual article page, where all i want to do is share the URL of the page - any ideas? Anyone else have any ideas? I am sure i have missed something very simple here!
            • 38723
            • 165 Posts
            Quote from: Emily at Jun 10, 2014, 07:32 AM
            Hi Tyreal, Sorry to come back to this discussion again. We've now gone live, but the code i've used (as per your example above), only works on the Articles Container page (where multiple news items are listed, along with the corresponding social media share buttons), but the same code does not work on the actual article page, where all i want to do is share the URL of the page - any ideas? Anyone else have any ideas? I am sure i have missed something very simple here!

            Are you wanting "Like" or "Shares" for Facebook?
            Are you just wanting a "Tweet" button that opens a window with part of the Tweet partially populated?

            I use a little Javascript thingy that takes a bunch of data attributes from links on the page and opens either a Facebook or Twitter share window.
            https://github.com/pdincubus/sharerbuttonatron

            I've used it a few times on CMS sites and it's nice because you can easily set the attributes up using MODX placeholders. There's info in the readme and in the comments in the JS.

            I try to avoid official Facebook/Twitter buttons because they're not all that customisable and are always the last thing to load - really infuriating. Using a plugin to create your own sharer links means you can style them however you want.

            Hope this helps! smiley
              • 38723
              • 165 Posts
              Quote from: Emily at Jun 10, 2014, 07:32 AM
              Hi Tyreal, Sorry to come back to this discussion again. We've now gone live, but the code i've used (as per your example above), only works on the Articles Container page (where multiple news items are listed, along with the corresponding social media share buttons), but the same code does not work on the actual article page, where all i want to do is share the URL of the page - any ideas? Anyone else have any ideas? I am sure i have missed something very simple here!

              Just noticed this, you're probably going to need to change [[~[[+id]]]] for [[~[[*id]]]] on the actual page as the plus is a placeholder not likely available on the actual article, whereas *id is always available for the page you're on.
                • 30912
                • 463 Posts
                Sorry - i havent been checking the forum as much as i'm no longer an active web developer anymore smiley

                pdincubus is right, you will need to change the syntax from placeholder to template variable.

                Sorry for the miss smiley
                  • 37928
                  • 14 Posts
                  Quote from: Emily at May 12, 2014, 02:45 PM
                  Hi,
                  Does anyone have any advice or ideas on what the best way is to add Facebook Like, Tweet and g+1 buttons to each news story within Articles, such that people can like/tweet/share individual articles/pages and not a generic URL (i.e. www.mydomain.co.uk/news/great-news-story as opposed to www.mydomain.co.uk). The code generated from Facebook developers for example asks for a generic URL, but i want it to be specific to the article, both on the actual article page and in the articles container page, where 10 articles are listed......

                  Any ideas? Using Revo

                  I used this: http://madaboutbrighton.net/projects/bookmarkthis - Im not sure if its still maintained, but its working Ok on a site that needed this funcitonality. I just updated the icons to something more modern, but it worked fine.
                    Dan
                    Web Developer