Not a developer? Go to MovableType.com

Documentation

buildfilefilter

This filter is called when Movable Type wants to rebuild a file, but before doing so. This gives plugins the chance to determine whether a file should actually be rebuilt in particular circumstances.

Input Parameters

  • $cb - a reference to the current MT::Callback object handling this event.
  • $args - An associative array that identifies the page being built.

The $args input parameter is a hash, or associative array with the following keys:

  • Context - Holds the template context that has been constructed for building (see MT::Template::Context).

  • ArchiveType - The archive type of the file, usually one of ‘Index’, ‘Individual’, ‘Category’, ‘Daily’, ‘Monthly’, or ‘Weekly’.

  • TemplateMap - An MT::TemplateMap object; this singles out which template is being built, and the filesystem path of the file to be written.

  • Blog - The MT::Blog object representing the blog whose pages are being rebuilt.

  • Entry - In the case of an individual archive page, this points to the MT::Entry object whose page is being rebuilt. In the case of an archive page other than an individual page, this parameter is not necessarily undefined. It is best to rely on the $at parameter to determine whether a single entry is on deck to be built.

  • PeriodStart - In the case of a date-based archive page, this is a timestamp at the beginning of the period from which entries will be included on this page, in Movable Type’s standard 14-digit “timestamp” format. For example, if the page is a Daily archive for April 17, 1796, this value would be 17960417000000. If the page were a Monthly archive for March, 2003, $start would be 20030301000000. Again, this parameter may be defined even when the page on deck is not a date-based archive page.

  • Category - In the case of a Category archive, this parameter identifies the category which will be built on the page.

  • FileInfo - If defined, an MT::FileInfo object which contains information about the file. See MT::FileInfo for more information about what a MT::FileInfo contains. Chief amongst all the members of MT::FileInfo, for these purposes, will be the “virtual” member. This is a boolean value which will be false if a page was actually created on disk for this “page,” and false if no page was created (because the corresponding template is set to be built dynamically).

    It is possible for the FileInfo parameter to be undefined, namely if the blog has not been configured to publish anything dynamically, or if the installation is using a data driver that does not support dynamic publishing.

Return Value

None.

Example Handler

    sub build_file_filter {
        my ($cb, %args) = @_;
        if ($args->{Entry}->author->name eq "Byrne") {
            return 0; # don't publish anything by Byrne
        } 
        return 1;
    }
Back

1 Comment

Matt Potosnak

Matt Potosnak on January 24, 2011, 6:08 a.m. Reply

Line 3 should be: if ($args{Entry}->author->name eq “Byrne”) {

$args is in fact passed as an array to be coerced into an hash.