<<

NAME

MT::TemplateMap - Movable Type archive-template association record

SYNOPSIS

    use MT::TemplateMap;
    my $map = MT::TemplateMap->new;
    $map->blog_id($tmpl->blog_id);
    $map->template_id($tmpl->id);
    $map->archive_type('Monthly');
    $map->file_template('<$MTArchiveDate format="%Y/%m/index.html"$>');
    $map->is_preferred(1);
    $map->save
        or die $map->errstr;

DESCRIPTION

An MT::TemplateMap object represents a single association between an Archive Template and an archive type for a particular blog. For example, if you set up a template called Date-Based and assign to the Monthly archive type in your blog, such an association will be represented by one MT::TemplateMap object.

USAGE

As a subclass of MT::Object, MT::TemplateMap inherits all of the data-management and -storage methods from that class; thus you should look at the MT::Object documentation for details about creating a new object, loading an existing object, saving an object, etc.

DATA ACCESS METHODS

The MT::TemplateMap object holds the following pieces of data. These fields can be accessed and set using the standard data access methods described in the MT::Object documentation.

  • id

    The numeric ID of the template map record.

  • blog_id

    The numeric ID of the blog with which this template map record is associated.

  • template_id

    The numeric ID of the template.

  • archive_type

    The archive type; should be one of the following values: Individual, Daily, Weekly, Monthly, or Category.

  • file_template

    The Archive File Template for this particular mapping; this defines the output files for the pages generated from the template for this archive type, using standard MT template tags.

  • is_preferred

    A boolean flag specifying whether this particular template is preferred over any others defined for this archive type. This is used when generating links to archives of this archive type--the link will always link to the preferred archive type.

METHODS

  • save()

    Saves the object. It also rearranges blog's archive type. If the saved template map is new and there is no other template maps with the same archive type has been, the archive type is also added to the blog.

  • remove()

    Removes template maps specified in terms and args (if called as class method) or the template map (if called as instance method). It also rearrange blog's archive types which are used to determine what types of archive will be published during rebuild. If template map is removed and there remains no template map with the archive type, the archive type is removed from blog's archive types to be rebuilt.

  • prefer(boolean)

    Set the template map preferred or not, depending on the argument. If the map has been preferred and is being unpreferred, and if there are any other MT::TemplateMap objects defined for this particular archive type and blog, the first of the other objects will be set as the preferred object. Its is_preferred flag will be set to true. If the map is the only MT::TemplateMap object for the blog and the archive type, the method does nothing - the map continues to be preferred.

DATA LOOKUP

In addition to numeric ID lookup, you can look up or sort records by any combination of the following fields. See the load documentation in MT::Object for more information.

  • blog_id
  • template_id
  • archive_type
  • is_preferred

NOTES

  • $obj->remove()

    When you remove a MT::TemplateMap object using MT::TemplateMap::remove, if the $map object you are removing has the is_preferred flag set to true, and if there are any other MT::TemplateMap objects defined for this particular archive type and blog, the first of the other objects will be set as the preferred object. Its is_preferred flag will be set to true.

AUTHOR & COPYRIGHT

Please see "AUTHOR & COPYRIGHT" in MT.

<<