phpLD Mod : social bookmarking
juust | 19/08/2008I was looking for a plugin to make it easy for people to bookmark their link-pages for my search engine optimized link directory. If they can add a bookmark and help get the page crawled, indexed, and ranked, I get a brutal backlink-count and fast increasing pagerank (free listing for a reciprocal).
So today I make a phpLD Bookmark-Mod ! I want one routine that puts the specific url of any page with the category title as bookmark-link in the page. For the example I took ekstreme.com, they have a page with most major bookmarking sites, from there you can add url+title to any ’social’ site.
How?
By using the apache server variables, $_SERVER["HTTP_HOST"] and $_SERVER["REQUEST_URI"]
phpLD uses index.php to generate all the link pages (it’s only one actual file). I will add some code to index.php to retrieve the ‘current’ category page url.
As my site uses seo-friendly mod_rewrite, the url contains the category names, so I extract the path from http://links.trismegistos.net/health/senior_health/ and replace the slashes with spaces, and it becomes my title “health senior health”
-
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
-
$PT=parse_url($URL, PHP_URL_PATH);
-
$PTT=trim(preg_replace('/\//', ' ', $PT));
-
$TITLE = "Trismegistos Links ".$PTT;
Now I need to get phpLD to list that anchor.
phpLD uses Templates (traditional data-functions-form (mysql, php, smarty)).
That means you cannot place php snippets directly in the forms. Luckily I have the $TPL-object in the php functions layer, which has a function to assign a value to a variable and store it in the template engine, and once the output file is made (the form) any reference i make to the variable in the template is replaced with the value stored in it.
So I make the variable “socialize” in $tpl and assign the anchor I made to it.
-
$TITLE = urlencode($TITLE);
-
$URL = urlencode($URL);
-
-
$socialize = "<a href=\"http://ekstreme.com/socializer/?url=$URL&title=$TITLE\" rel=\"nofollow\" target=\"_blank\">Socialize!</a>";
-
-
$tpl->assign('socialize', $socialize);
Now the anchor is stored in the $tpl-object, the template engine, and I can list the content of any variable stored in the ‘engine’ between {}. I pick FOOTER.TPL and add the reference {$socialize}.
-
<table><tbody>
-
<tr><td>pending</td><td>{$pending_links}</td><td>{$socialize}</td></tr>
-
</tbody></table>
I store the php function in a file socialize.php in the root of the directory, and the last step is putting the extra routine in index.php :
-
require_once 'socialize.php';
…right after require_once ‘init.php’
every time a new page is loaded, the routine is executed, retrieves the current url from the server, makes a new anchor and shows it on the page as bookmark link. Exactly what I wanted.
Have a look at links.trismegistos.net – health – senior health, in the footer you see Socialize!, the link takes you to the ekstreme.com site where you get a list of all bookmarking sites available.
Feel free to cut-and-paste it, it’s 10 lines of code.
-
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
-
$PT=parse_url($URL, PHP_URL_PATH);
-
$PTT=trim(preg_replace('/\//', ' ', $PT));
-
$TITLE = "Trismegistos Links ".$PTT;
-
$TITLE = urlencode($TITLE);
-
$URL = urlencode($URL);
-
$socialize = "<a href=\"http://ekstreme.com/socializer/?url=$URL&title=$TITLE\" rel=\"nofollow\" target=\"_blank\">Socialize!</a>";
-
$tpl->assign('socialize', $socialize);








