November 18, 2003

[MovableType] Customize Movable Type's default templates

If you desided to use Movable Type as a website publish platform for some group, community, or company, etc., you would like to apply the same templates to make all your site pages look and feel alike. Sure you can use the "link this template to a file" function in template editing screen. But then all templates in different weblog will be linked. Except this, you still have to setting this link manually. If yor are using "Template Module" to form your templates, this uncomfortable dream will become nightmare.

In such a situration, you must want to transfer your hard-working-templates into Movable Type's default template. With this default template, Movable Type will prepare all templates for you when you creating any new weblog. Then you only have to modify them to present the real situration. This is not only a dream. All you have to do, is editing this file with any plain-text editor:

where_your_MT_was_installed/lib/MT/default-templates.pl

This is not really hard. Even my kind of programming idiot can do. But never forget to backup before any modify. There is no guarantee.

This file is quite simple in fact. It says:

[
{
'text' => 'content of Main Index template',
'outfile' => 'index.html',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'Main Index'
},

{
'text' => 'content of RSD template',
'outfile' => 'rsd.xml',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'RSD'
},

{
'text' => 'content of RSS 2.0 template',
'outfile' => 'index.xml',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'RSS 2.0'
},

{
'text' => 'content of Main Archive Index template',
'outfile' => 'archives.html',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'Main Archive Index'
},

{
'text' => 'content of Comment Preview template',
'type' => 'comment_preview',
'name' => 'Comment Preview Template'
},

{
'text' => 'content of Comment Error template',
'type' => 'comment_error',
'name' => 'Comment Error Template'
},

{
'text' => 'content of Popup Uploaded Image template',
'type' => 'popup_image',
'name' => 'Popup Uploaded Image Template'
},

{
'text' => 'content of Comments Listing template',
'type' => 'comments',
'name' => 'Comments Listing Template'
},

{
'text' => 'content of RSS 1.0 template',
'outfile' => 'index.rdf',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'RSS 1.0'
},

{
'text' => 'content of Styles Sheet template',
'outfile' => 'styles-site.css',
'rebuild_me' => '1',
'type' => 'index',
'name' => 'Styles Sheet'
},

{
'text' => 'content of Date Based Archive template',
'type' => 'archive',
'name' => 'Date Based Archive'
},

{
'text' => 'content of Category Archive template',
'type' => 'category',
'name' => 'Category Archive'
},

{
'text' => 'content of Individual Entry Archive template',
'type' => 'individual',
'name' => 'Individual Entry Archive'
},

{
'text' => 'content of TrackBack Pings Listing template',
'rebuild_me' => '0',
'type' => 'pings',
'name' => 'TrackBack Pings Listing Template'
},

{
'text' => 'paz',
'type' => 'custom',
'name' => 'module'
},

]

You will find that this is just a array reference of hash reference if you can understand Perl. Don't think about geek's Perl. Let's watch this file just with your instinct (the Force?):

  1. This file begins with a "[", and ends with a "]". All templates are listed between them;
  2. Each template begins with a "{", ends with a "}", and diverged by a ",";
  3. All content in each template using the "'A' => 'B'" format, means we want to fill "B" in column "A".

Now things go better. You can find this out if you keep working harder:

Possible column
LabelMeaningsNote
textTemplate BodyYou can paste whole template, including line-break
outfileOutput filePlease enter the whole filename
rebuild_meRebuild this template when rebuilding Index templates1 means yes, while 0 means no
typeType of templatePlease see below
nameTemplate NamePlease enter the name of this template

We don't finish yet. You have to figure out what "type of template" is available. More then this, each type of template required different set of other columns. Maybe you have to use the Source or use the Force. Never worry about this. I've already digested for you:

Type of template
TypeNameColumns can be used
Index templatesindexoutfile, rebuild_me, name
Date Based Archive templatesarchiveN/A
Category Archive templatescategoryN/A
Indinidual Entry Archive templatesindividualN/A
Comments Listing TemplatecommentsN/A
Comment Preview Templatecomment_previewN/A
Comment Error Templatecomment_errorN/A
TrackBack Pings Listing TemplatepingsN/A
Popup Uploaded Image Templatepopup_imageN/A
Template ModulescustomN/A

Hey, don't be such hurry. Please note that if there is any "'" in your "Template Body," you have to add a extra "\" in front of it turning it into "\'". Otherwise you will get a "Can't find default template listing; where is default-templates.pl?" error message.

Well, that's all. You can now play in your own, or wait me packing my own templates into a single default-templates.pl in days.

Posted by Jedi at November 18, 2003 10:19 PM | 中文版 (Chinese Version) | TrackBack (0)
Comments
[ 1 : Permalink ]

Instead od of using:
'text' => 'Testing',
can you use:
'linked_file' => '../index.tmpl',
in the default-templates.pl file to create all the weblogs identically?

You can change on any weblog edit template page and it will update the template file.

My concern is synchronization or lockup.

Thanks for any help

Ted

Posted by Theodore Balaban at April 28, 2004 03:42 AM
[ 2 : Permalink ]

Well, I think that might work. But I don't sure if this will overwrite the template content in your default-templates.pl file.

Maybe you just can spend some times to test.

Good luck.

Posted by Jedi at October 12, 2004 08:28 AM
Leave Your Comments
Personal Informaion








Remember personal info?



Enter the Security Code shown above:
Comment Area




Jedi.org: BLOG (zh) | Weblog (Eng.) | Organism | Kwiki | S5 | TKSlide | MTBook (zh) | DIA (zh) | Résumé (Eng.) | Statistics