ncyoung.com

Referers (linkback) in b2.

This entry is in the following categories:

I fixed my b2 blog to show referring pages from the permalink or comments view of a weblog entry.



Here are instructions for making this modification:



  • 1. Download the refererlog code from:

    http://ncyoung.com/code/zip/refererLib.zip

    More info available at:

    http://ncyoung.com/code.php

  • 2. Edit refererLib.php, placing your database connection variables in the connect statements at the top of the file. If you want the library to ignore internal links (i.e. those from one page to another within your own site) you must add your domain to the "ignore" array. If there are other sites whose referrals you'd like ignored, you may add them to the "ignore" array as well.

  • 3. Place the library in your b2 directory.

  • 4. visit http://path_to_b2/refererLib.php?createTable=1 to create the database table to hold referers.

  • 5. At the top of your main blog template, you should see a statement like:

    include ("blog.header.php");

    Right after this, add a statement:

    include ("refererLib.php");

  • 6. Again in your main blog template but much further down: Right before

    the line that says:

    < ?php include ("b2comments.php"); ?>

    insert the following code:



    ---------------------------code start

    < ?php

    if ($p && $c){

      logReferer();

      $list = refererList(20);

      if ($list){

        print "<br>Pages that link to this one:";

        foreach ($list as $link){

          print " < - $link<BR>";

        }

        print "<br>";

      }

    }

    ?>

    ---------------------------code end



  • 7. That's it





Update (7/22/02)

This modification posted at Adam Walker's site



Dated: 07/19/2002