Anil Dash mentions on his weblog that google prefers filenames with dashes, not underscores so I cobbled together this simple plug-in to dirify... but with dashes. Just save the following code as dirifydashes.pl in MT's plugins directory. Then use dirifydashes="1" instead of dirify="1" in your templates.
CODE
# Dirifydashes 1.0
# Same as dirify but converts space chars to dashes
use strict;
use MT::Template::Context;
use MT::Util qw( convert_high_ascii );
use MT::Util qw( remove_html );
MT::Template::Context->add_global_filter(dirifydashes => sub {
my $s = $_[0];
$s = convert_high_ascii($s); ## convert high-ASCII chars to 7bit.
$s = lc $s; ## lower-case.
$s = remove_html($s); ## remove HTML tags.
$s =~ s!&[^;\s]+;!!g; ## remove HTML entities.
$s =~ s![^\w\s]!!g; ## remove non-word/space chars.
$s =~ tr! !-!s; ## change space chars to dashes.
$s;
});
# Same as dirify but converts space chars to dashes
use strict;
use MT::Template::Context;
use MT::Util qw( convert_high_ascii );
use MT::Util qw( remove_html );
MT::Template::Context->add_global_filter(dirifydashes => sub {
my $s = $_[0];
$s = convert_high_ascii($s); ## convert high-ASCII chars to 7bit.
$s = lc $s; ## lower-case.
$s = remove_html($s); ## remove HTML tags.
$s =~ s!&[^;\s]+;!!g; ## remove HTML entities.
$s =~ s![^\w\s]!!g; ## remove non-word/space chars.
$s =~ tr! !-!s; ## change space chars to dashes.
$s;
});
Note: Since writing this plug-in I've found DirifyPlus but it's slightly more difficult to use.
All the best,
--
Ian Fenn
Chopstix Media