juust ~ php oddities

Unordered list of one element
  • rss
  • begin
  • about
    • vcard
    • WTF is BroJesus
  • php scripts
    • flickr wp widget
    • google multi key serp tool, php script
    • gwt plugin
  • php classes
    • php pagerank class
    • fibonacci class
    • robots.txt parser php class
  • serp
    • serp dashboard wordpress plugin
  • services

phpLD Mod : social bookmarking

juust | 19/08/2008

I 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”

  1. $URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
  2. $PT=parse_url($URL, PHP_URL_PATH);
  3. $PTT=trim(preg_replace('/\//', ' ', $PT));
  4. $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.

  1. $TITLE = urlencode($TITLE);
  2. $URL = urlencode($URL);
  3.  
  4. $socialize = "<a href=\"http://ekstreme.com/socializer/?url=$URL&amp;title=$TITLE\" rel=\"nofollow\" target=\"_blank\">Socialize!</a>";
  5.  
  6. $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}.

  1.  <table><tbody>
  2.   <tr><td>pending</td><td>{$pending_links}</td><td>{$socialize}</td></tr>
  3.         </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 :

  1.    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.

  1. $URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
  2. $PT=parse_url($URL, PHP_URL_PATH);
  3. $PTT=trim(preg_replace('/\//', ' ', $PT));
  4. $TITLE = "Trismegistos Links ".$PTT;
  5. $TITLE = urlencode($TITLE);
  6. $URL = urlencode($URL);
  7. $socialize = "<a href=\"http://ekstreme.com/socializer/?url=$URL&amp;title=$TITLE\" rel=\"nofollow\" target=\"_blank\">Socialize!</a>";
  8. $tpl->assign('socialize', $socialize);
Categories
links, optimisation, pagerank
Tags
links, optimisation, pagerank, php
Comments rss
Comments rss
Trackback
Trackback

« social bookmarking to get your site indexed php link directory mod : page rank per page »

Leave a Reply

Click here to cancel reply.

Recent Posts

  • Pagerank sculpting session
  • wish you were here
  • interesting : seo panel
  • availability test
  • Mayday

click me!
rss
Comments rss
Blog Directory
Web Developement Blogs - BlogCatalog Blog Directory
Listed in LS Blogs the Blog Directory and Blog Search Engine
Blog Flux Directory
joopita.com free web directory and search engine
design by jide
sitemap
17240 confirmed spam kills