B2Links – link organiser for b2, and other updates

I mentioned B2Links before but it’s been renamed. The one final feature missing from it is polling weblogs.com to see if each link has been updated in the last x minutes/hours. I might take a look at this next week!

On the b2++ front – I discovered a bug when new users register. Sometimes their blog template isn’t copied over properly. Just login (at the b2login.php url sent to you in the email) and choose another template. A fix will be in the next snapshot, maybe tonight.
I should also make more checks for mod_rewrite in the install process, as at least person had trouble with it. That should be a simple 3 line fix though!
Tim mailed me a long list of features he’d like to see in b2++, as well as suggesting a name change for the project as it’s diverging quite a bit from the original b2. Leave a comment if you have any ideas!
I’d also like to hear from b2 mod/hack authors as the plugin system of b2++ will make it quite easy for original b2 hacks to be incorporated and distributed. When I get around to Smartyising the backend, it’ll be much easier to add stuff there!

b2++ 0.5

New release last night! This one fixes more install bugs, adds plugin support and with the plugins I’ve been talking about here over the last few days! It’s probably better if you download the src and data packages, as there’s been a few updates to the templates. Go download it!

Search term highlighting on my site

Keith posted about his efforts to highlight Google search terms. This is interesting! I may be able to create a b2-prefunction that does the same for b2++.
Update! I modified my original highlightsearch() function, adding in most of the code found on textism.org which also fixes the problem of highlighting text inside html links! Woo!
Here’s a Google search for you to try. Hit the Holy Shmoly link to see the highlighted text!
Again, if you want to add this to your own blog, just edit post.tpl add add the highlightsearch modifier around $the_content:

{$the_content|highlightsearch}

You’ll then have access to lots of highlighted search results!

new b2 snapshot

I released a new b2 snapshot today. This is the first release I’ve testing in Windows. By default Apache on Windows doesn’t enable mod_rewrite so I added code to catch when that happens.
Here’s the b2 discussion board I announced the new release on.
Download the new snapshot. You should probably download both the src and data packages as there are a number of template fixes too.

b2 Search Highlight Modifier

There’s a nice generalised text highlighter on the Smarty Plugins Wiki page so I modified it slightly to highlight b2 searches! Here’s a search for smarty that shows off this new plugin.
How do you use it? Modify your post.tpl and add the modifier to the_content variable like this:

{$the_content|highlightsearch}

If you want different colours try this:

{$the_content|highlightsearch:”<b style=’color: #000; background-color: #f00;’>”:”</b>”}

Text inside html links is also modified so links may be broken. Is there an easy way around that?
Here’s the code for the modifier. Just place it into a file called “modifier.highlightsearch.php” in your plugins directory!

<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: highlight
* Version: 0.5
* Date: 2003-03-27
* Author: Pavel Prishivalko, aloner#telephone.ru
* Purpose: Highlight search term in text
* Install: Drop into the plugin directory
*
* Extended To 0.5 By: Alexey Kulikov
* Strips Tags for nice output, allows multiple term for highlight
* Modified and simplified to high light b2 searches by Donncha O Caoimh
* -------------------------------------------------------------
*/
function smarty_modifier_highlightsearch($text, $start_tag='<b style="color: #000; background-color: #ff0;">', $end_tag='</b>')
{
   global $s;
   if( $s != '' )
   {
     $term = $s;
     $term = preg_quote($term);

     return preg_replace('/('.$term.')/i', $start_tag.'$1'.$end_tag, $text);
   }
   else
   {
     return $text;
   }
}

?>

A year ago today

I added the “A Year Ago Today” Plugin to the site. Use it by adding the following Smarty tag to your site template (ie. in index.tpl)

{todayayearago heading='<h1>A Year Ago</h1>’}

There are a number of differences between this plugin and the original:

  1. The “heading” part is the heading displayed if there are any posts, otherwise nothing is displayed.
  2. If no title exists for the old entry, then an extract of the old entry is printed.
  3. I fixed a bug with the $siteurl variable.

Unfortunately, there were no posts on 2002-04-25, but there were on 2002-04-26 so you’ll see them pop up tomorrow!