⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templatemap.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
字号:
# Copyright 2001-2005 Six Apart.# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS## $Id: TemplateMap.pm 10197 2005-03-09 00:27:57Z ezra $package MT::TemplateMap;use strict;use MT::Object;@MT::TemplateMap::ISA = qw( MT::Object );__PACKAGE__->install_properties({    columns => [        'id', 'blog_id', 'template_id', 'archive_type',        'file_template', 'is_preferred',    ],    indexes => {        blog_id => 1,        template_id => 1,        archive_type => 1,        is_preferred => 1,    },    datasource => 'templatemap',    primary_key => 'id',});sub remove {    my $map = shift;    if ($map->is_preferred) {        my @all = MT::TemplateMap->load({ blog_id => $map->blog_id,                                          archive_type => $map->archive_type });        @all = grep { $_->id != $map->id } @all;        if (@all) {            $all[0]->is_preferred(1);            $all[0]->save;        }    }    $map->SUPER::remove;}1;__END__=head1 NAMEMT::TemplateMap - Movable Type archive-template association record=head1 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;=head1 DESCRIPTIONAn I<MT::TemplateMap> object represents a single association between anArchive Template and an archive type for a particular blog. For example, ifyou set up a template called C<Date-Based> and assign to the C<Monthly>archive type in your blog, such an association will be represented by oneI<MT::TemplateMap> object.=head1 USAGEAs a subclass of I<MT::Object>, I<MT::TemplateMap> inherits all of thedata-management and -storage methods from that class; thus you should lookat the I<MT::Object> documentation for details about creating a new object,loading an existing object, saving an object, etc.=head1 DATA ACCESS METHODSThe I<MT::TemplateMap> object holds the following pieces of data. Thesefields can be accessed and set using the standard data access methodsdescribed in the I<MT::Object> documentation.=over 4=item * idThe numeric ID of the template map record.=item * blog_idThe numeric ID of the blog with which this template map record is associated.=item * template_idThe numeric ID of the template.=item * archive_typeThe archive type; should be one of the following values: C<Individual>,C<Daily>, C<Weekly>, C<Monthly>, or C<Category>.=item * file_templateThe Archive File Template for this particular mapping; this defines the outputfiles for the pages generated from the template for this archive type,using standard MT template tags.=item * is_preferredA boolean flag specifying whether this particular template is preferred overany others defined for this archive type. This is used when generating linksto archives of this archive type--the link will always link to the preferredarchive type.=back=head1 DATA LOOKUPIn addition to numeric ID lookup, you can look up or sort records by anycombination of the following fields. See the I<load> documentation inI<MT::Object> for more information.=over 4=item * blog_id=item * template_id=item * archive_type=item * is_preferred=back=head1 NOTES=over 4=item *When you remove a I<MT::TemplateMap> object using I<MT::TemplateMap::remove>,if the I<$map> object you are removing has the I<is_preferred> flag set totrue, and if there are any other I<MT::TemplateMap> objects defined for thisparticular archive type and blog, the first of the other objects will beset as the preferred object. Its I<is_preferred> flag will be set to true.=back=head1 AUTHOR & COPYRIGHTSPlease see the I<MT> manpage for author, copyright, and license information.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -