Help - Search - Members - Calendar
Full Version: Works In Foreground, Doesn't Work In Background
Movable Type Community Forum > Additional Resources > Plugin Development and Usage
ocwo92
I have a global filter plug-in that uses MT's template building capability to transform a text section according to a template.

It works fine when the blog is published in the foreground (that is, background publishing is turned off). The code looks like the following, where I'm creating a new template and want to use the "build_page" method to build the proper output based on the template. (The parameters passed to the template in the build_page call are left out for simplicity.):

CODE
my $tmpl = new MT::Template;
$tmpl->text( $myTemplate );
my $app = MT->instance;
my $myOutput = $app->build_page( $tmpl, { } );

But, when I turn background publishing on, the run-periodic-tasks script fails on build with the following error (MT4.1):

QUOTE
Eval failure: Can't locate object method "mode" via package "MT" at ../lib/MT.pm line 1931.

Can anyone tell me what I need to do in order to make this section work in background mode as well? And, can you perhaps tell me why it isn't working in background mode?
ocwo92
QUOTE (ocwo92 @ Jun 17 2008, 03:34 PM) *
Can anyone tell me what I need to do in order to make this section work in background mode as well?

Hunh. Sometimes I think I should publish my official problem-solving method somewhere and make money off it:
  1. Go the appropriate forum and ask.
  2. Wait 30 minutes.
  3. Have another beer.
  4. Post the solution that you found in the meantime:
In this particular case, use build_page_in_mem(...) instead of build_page(...).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.