Make Your Own Social Bookmarking Links in Non-Wordpress Website
on Feb 26in Developers Toolbox, PHP, Tutorials tagged php tutorials, social bookmarking tutorials by jamesIn my last post, I showed how to make your own social bookmarking links in your Wordpress Theme. What if you wanted to put the social bookmarking links into your non-wordpress webpage? In this tutorial, I will outline how to include your social bookmarking links into your web page using PHP scripting.
1. Open you favorite PHP editor and navigate to the line where you want to position the social bookmarking icons. Our first task would be to grab the existing URL of our website. It can be done by using the following script:
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].
$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
2. Once you have grab the current URL, you need to pass it your social bookmarking links. This is quite easy since we will only need to use the php echo syntax.
<div class="socialbookmarking"> <h3>Share This Post!<h3> <a href="http://www.stumbleupon.com/submit?url=<?php echo $curPageUrl; ?>title="StumbleUpon.">StumbleUpon</a> | <a href="http://www.reddit.com/submit?url=<?php echo $curPageUrl; ?>title="Vote on Reddit.">Reddit</a> | <a href="http://del.icio.us/post?url=<?php echo $curPageUrl; ?>title="Share on Delicious">Delicious</a> | <a href="http://digg.com/submit?url=<?php echo $curPageUrl; ?>title="Digg This">DIGG</a>
3. Test the code in your browser. The only thing to do now is to design the links according to your design preferences.
That’s it. We have finally made a social bookmarking links to our non-wordpress web site.
Share this Post.
There are no comments yet, add one below.




