Search code examples
htmlcsssocial-networking

Bootstrap social share button


I'm trying to add some social share buttons on my blog with Bootstrap, but I'm not getting how to put the URL from the site after the link of the Twitter /share.

This is the code:

<a href="https://twitter.com/share" class="btn btn-social btn-twitter">
                  <i class="fa fa-twitter"></i> Share on Twitter</i>
</a>

---------- Edited: Now it's half working. I've made a function that open a popup, the link-in-popup:

 <a href="http://www.facebook.com/sharer.php?u=" class="btn btn-social btn-facebook link-in-popup">
     <i class="fa fa-facebook"></i> Share on Facebook</i>
 </a>

But only open the link "https://www.facebook.com/sharer/sharer.php?u", how do I get the url of the page after the "u"? Twitter itself opens the popup with the link, but not facebook. I need something like " <a href="http://www.facebook.com/sharer.php?u=[URLPAGE]"


Solution

  • Now it's working completely!

    Here's the code:

    <a href="http://www.facebook.com/sharer.php?u=<?php echo(($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); ?>" class="btn btn-social btn-facebook link-in-popup">
              <i class="fa fa-facebook"></i> Share on Facebook</i>
    </a>
    

    The php gets the current url. I'm just finding out a way to this whole php code turns into a variable. Thank you all!