Getting XFN Working in b2evo

I just realized that I never wrote this up, even though I added it to my site way back in September.

This is how you can set up your b2evo blog to be XFN-Friendly.

Read on for the step-by-step.

  1. Set up your XFN Blog

    Create a new blog called “XFN” or something like that.

    For example: http://isaacschlueter.com/xfn

    I’d recommend unchecking the “Include in public blog list” box, since this is more a “utility” blog than an actual list of posts, but you can include it if you’d like.

  2. Create categories in this blog for each sort of relationship.

    You can group
    them heirarchically, as well, and this allows for viewing all of the “Family” links together, etc.

  3. Create the xfn functionality in hacks.php:


    // set this to the ID of the blog where you store
    // the XML Friends Network relationships
    $xfn_blog = 8;
    function xfn(& $Item, $disp = true)
    {
      global $xfn_blog;

      $categoryIDs = postcats_get_byID($Item->ID);
      $xfn = array();
      foreach( $categoryIDs as $cat_ID )
      {
        $cat = get_the_category_by_ID($cat_ID);
        $cat_name = format_to_output( $cat['cat_name'], ‘htmlattr’ );
        $cat_blog = get_catblog($cat_ID);
        if( $cat_blog == $xfn_blog ) $xfn[] = $cat_name;
      }
      if( $xfn ) $xfn = ‘ rel=”‘ . implode(’ ‘,$xfn) . ‘”‘;
      else $xfn = false;
      if( $disp && $xfn ) echo $xfn;
      return $xfn;
    }

  4. Turn it on

    In b2evocore\_class_item.php, find this bit:

    if( $add_link && (!empty($this->url)) )
    {
      $title = ‘<a href=”‘.$this->url.’”>’.$title.’</a>’;
    }

    Change it to this:

    if( $add_link && (!empty($this->url))
    {
      $title = ‘<a href=”‘.$this->url.’”‘ . xfn($this, false) . ‘>’.$title.’</a>’;
    }

  5. Add the profile attrib to your HEAD tag in skins/whatever/_main.php to be uber-XHTML-compliant

    You can either create your own profile like this:
    <head profile="http://yourblogsite/your/xfn/profile/page">

    Or you can point at an existing XFN profile that meets your neetds, such as:<head profile="http://isaacschlueter.com/blog/isaacs_xfn_profile">
    or
    <head profile="http://gmpg.org/xfn/11">

  6. Allow cross-blog posting in b2evo

    See your conf/_advanced.php or _admin.php or something, I forget.

  7. Add the relationship category as a second category to any blog posts that are relationship links.

    That is, check the checkbox, don’t plug the radio button. Unless, of course, you want the relationship to be the main category (i.e., for your mother’s blog, or something like that.)

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.