Rebuilding Movable Type Using PHP
November 11, 2005 12:01 PM Subscribe
How do I trigger the rebuild of a MT blog using PHP?
I'm working on a way to allow anonymous users to submit suggested entries to my blog (initially as a draft) and then later activate them (switch the status to post, then rebuild the blog), all outside the MovableType interface.
I've gotten everything working right up until the step where I rebuild. Now I'm stuck. What I'd really like to do is use MT-Rebuild by following this guy's process:
http://www.cadenhead.org/workbench/news/2392
Unfortunately, I don't get how I should be modifying his example for my own situation. Here's what I've tried (among several things) without success:
system("$this->/usr/bin/perl $this->/home/myaccount/public_html/mt/mt-rebuild.pl -all");
I'm a php novice, so I'm guessing I've got an error in that string.
Can anyone point out my error?
I'm also open to other suggestions, as long as it can be achieved from within php and doesn't expose the user to the Movable Type interface.
PS--To be clear, I've bought an unlimited authors license of MT. This is more about not wanting to force people to register as authors in order to post.
I'm working on a way to allow anonymous users to submit suggested entries to my blog (initially as a draft) and then later activate them (switch the status to post, then rebuild the blog), all outside the MovableType interface.
I've gotten everything working right up until the step where I rebuild. Now I'm stuck. What I'd really like to do is use MT-Rebuild by following this guy's process:
http://www.cadenhead.org/workbench/news/2392
Unfortunately, I don't get how I should be modifying his example for my own situation. Here's what I've tried (among several things) without success:
system("$this->/usr/bin/perl $this->/home/myaccount/public_html/mt/mt-rebuild.pl -all");
I'm a php novice, so I'm guessing I've got an error in that string.
Can anyone point out my error?
I'm also open to other suggestions, as long as it can be achieved from within php and doesn't expose the user to the Movable Type interface.
PS--To be clear, I've bought an unlimited authors license of MT. This is more about not wanting to force people to register as authors in order to post.
system("/home/myaccount/public_html/mt/mt-rebuild.pl -all");
However, I would probably just set a cron job to periodically run.
posted by tumble at 1:15 PM on November 11, 2005
However, I would probably just set a cron job to periodically run.
posted by tumble at 1:15 PM on November 11, 2005
I just wanted to say hi to jeanmari at this juncture of two of my favorite places online.
posted by john m at 3:23 PM on November 11, 2005
posted by john m at 3:23 PM on November 11, 2005
Response by poster: kcm - I haven't gotten a best answer yet. None of the suggestions so far have worked.
john m has actually gotten closest...he emailed me this:
system("/usr/bin/perl /home/myaccount/public_html/mt/mt-rebuild.pl -mode="entry" -blog_id=$entry_blog_id -entry_id=$entry_id");
That doesn't trigger the rebuild either. What it did uncover though is that if I strip out everything after .pl I can at least get the following to present in the browser:
mt-rebuild Usage: mt-rebuild.pl -mode="(all|archive|entry|index)" -blog_id=0 [-archive_type="(Individual|Daily|Weekly|Monthly|Category)" -no_indexes -entry_id=0 -build_dependencies -template="your template name" -force ] OR mt-rebuild.pl -all [-no_indexes] See the POD documentation embedded in this script for more detail. success
That leads me to believe I'm successfully hitting mt-rebuild.pl but I'm not successfully passing the instructions on.
I may just have to resort to the chron job suggested by tumble.
posted by jeanmari at 8:19 AM on November 12, 2005
john m has actually gotten closest...he emailed me this:
system("/usr/bin/perl /home/myaccount/public_html/mt/mt-rebuild.pl -mode="entry" -blog_id=$entry_blog_id -entry_id=$entry_id");
That doesn't trigger the rebuild either. What it did uncover though is that if I strip out everything after .pl I can at least get the following to present in the browser:
mt-rebuild Usage: mt-rebuild.pl -mode="(all|archive|entry|index)" -blog_id=0 [-archive_type="(Individual|Daily|Weekly|Monthly|Category)" -no_indexes -entry_id=0 -build_dependencies -template="your template name" -force ] OR mt-rebuild.pl -all [-no_indexes] See the POD documentation embedded in this script for more detail. success
That leads me to believe I'm successfully hitting mt-rebuild.pl but I'm not successfully passing the instructions on.
I may just have to resort to the chron job suggested by tumble.
posted by jeanmari at 8:19 AM on November 12, 2005
The system command you gave looks okay except for the -mode="entry" part -- do you have those inner " characters with a \ in front of them? Otherwise, you'd get a PHP syntax error. Also, the $entry_blog_id and $entry_id variables must be set to something valid.
posted by bschoate at 8:23 AM on November 14, 2005
# assuming these are valid $entry_blog_id = 1; $entry_id = 100; # the following should be on one line; i'm # just wrapping it for display purposes system("/usr/bin/perl /path/to/mt_dir/mt-rebuild.pl -mode=\"entry\" -blog_id=$entry_blog_id -entry_id=$entry_id -build_dependencies");Note that some shared web hosting companies will restrict PHP functions like system, but it looks like yours does not.
posted by bschoate at 8:23 AM on November 14, 2005
This thread is closed to new comments.
posted by kcm at 12:09 PM on November 11, 2005