Hope this will help others with this same problem--I'm using MT to run a website, more as a Content Mangement System than a single blog, so I have several blogs that all need to use the same templates. I just took the perl script that girlie linked above and copied everything but the last line
CODE
print "Finished: ".(localtime())."<br>\n";
for each blog. What I ended up with was one long file of this script repeating, and I just changed the blog number after I pasted the script. At the end of the scirpt, I made sure that the
CODE
print "Finished: ".(localtime())."<br>\n";
was tagged on to the end.
Initial testing shows that it works and it works fast when I enter changes to an index template. I'll keep working with it.
Here's an example for 2 blogs, note the repeating code and all that is changed is the blog id number.
CODE
#!/usr/bin/perl -w
use strict;
# Usage: mt-rebuild.pl
# add this to your cron file to automate rebuilds. example:
#
#0 0 * * * /path/to/mtdir/mt-rebuild.pl
#
# The above will rebuild blog #1 at 12 AM (your server's time)
print "Content-type: text/html \n\n";
# INSERT YOUR BLOG ID BELOW
my $blog_id = 1; # blog id here
if (!$blog_id) {
print STDERR "usage: mt-rebuild.pl (Blog ID)\n";
exit 1;
}
my($MT_DIR);
BEGIN {
if ($0 =~ m!(.*[/\])!) {
$MT_DIR = $1;
} else {
$MT_DIR = './';
}
unshift @INC, $MT_DIR . 'lib';
unshift @INC, $MT_DIR . 'extlib';
}
require MT;
my $mt = MT->new(Config => $MT_DIR . 'mt.cfg',
Directory => $MT_DIR);
require MT::Blog;
my $blog = MT::Blog->load($blog_id);
if (!$blog) {
print STDERR "failed to load blog $blog_id\n";
exit 1;
}
print "Rebuilding Blog: ".$blog->name."<br>\n";
print "Started: ".(localtime())."<br>\n";
$mt->rebuild(
BlogID => $blog_id,
EntryCallback => sub { print ' - ',$_[0]->title, '('.$_[0]->id.')', "<br>\n" }
);
#!/usr/bin/perl -w
use strict;
# Usage: mt-rebuild.pl
# add this to your cron file to automate rebuilds. example:
#
#0 0 * * * /path/to/mtdir/mt-rebuild.pl
#
# The above will rebuild blog #1 at 12 AM (your server's time)
print "Content-type: text/html \n\n";
# INSERT YOUR BLOG ID BELOW
my $blog_id = 2; # blog id here
if (!$blog_id) {
print STDERR "usage: mt-rebuild.pl (Blog ID)\n";
exit 1;
}
my($MT_DIR);
BEGIN {
if ($0 =~ m!(.*[/\])!) {
$MT_DIR = $1;
} else {
$MT_DIR = './';
}
unshift @INC, $MT_DIR . 'lib';
unshift @INC, $MT_DIR . 'extlib';
}
require MT;
my $mt = MT->new(Config => $MT_DIR . 'mt.cfg',
Directory => $MT_DIR);
require MT::Blog;
my $blog = MT::Blog->load($blog_id);
if (!$blog) {
print STDERR "failed to load blog $blog_id\n";
exit 1;
}
print "Rebuilding Blog: ".$blog->name."<br>\n";
print "Started: ".(localtime())."<br>\n";
$mt->rebuild(
BlogID => $blog_id,
EntryCallback => sub { print ' - ',$_[0]->title, '('.$_[0]->id.')', "<br>\n" }
);