Tweaking Movable Type
Oct 20th, 2005 by Karen
We’ve been in the process of installing Movable Type to use here for the Libraries’ weblogs. However, Movable Type doesn’t completely meet all of our needs out of the box. So the web developers and I have been working to tweak it. Some of the tweaking has been creating a template for the weblogs that matches the Libraries’ current web site. Another piece of the customization has been figuring out how to give all the blogs the same template without Web Services having to go in and tweak each blog manually. A big part of making the templates manageable is using what Movable Type calls “modules”. Modules are basically like server side includes. You can put code in them to be reused at any point and they are called using the <$MTInclude module=”name”$> tag. The advantage the modules have over server side includes is that you can use Movable Type tags in them. This makes them very helpful for constructing the page header and right navigation bar.
The only problem with modules is that when you create a new blog no modules are included in it. In addition, any new blog you create uses the Movable Type set of templates and you have to customize the templates from there. So what if you have your own set of templates that use modules that you want to use when every blog is created? Well, if this is the case then you need to do a bit of tweaking. There are two areas that need to be tweaked. The first is the default_templates folder which contains all of the default template files which are used when a new blog is created. This has things like main_index.tmpl, stylesheet.tmpl and rss2.tmpl You can edit any of these files and from this point forward any blog you create will have the changed templates. So let’s say you compartmentalize your code and break out the banner and sidebar so that you only have to update it once rather than changing it on the “Main Index” page and the “Archive Page”. This means that you end up having modules.
The first thing you need to do is compartmentalize the code so that the main_index.tmpl and master_archive.tmpl uses the <$MTInclude module=”name”$> tag to include the modules you want. Once you have done this you need to take the code for these modules and make them into .tmpl files that live in the default_templates directory. This isn’t enough though to get these modules to show up on every new blog though. The last thing you need to do is edit the default-templates.pl which lives in where_your_MT_was_installed/lib/MT .
The code in the file looks like this
my $templates = [
{
'outfile' => 'index.html',
'name' => 'Main Index',
'type' => 'index',
'rebuild_me' => '1'
},
{
'outfile' => 'mtview.php',
'name' => 'Dynamic Site Bootstrapper',
'type' => 'index',
'rebuild_me' => 1,
},
{
'outfile' => 'rsd.xml',
'name' => 'RSD',
'type' => 'index',
'rebuild_me' => '1'
},
{
'outfile' => 'atom.xml',
'name' => 'Atom Index',
'type' => 'index',
'rebuild_me' => '1'
},
{
'outfile' => 'index.xml',
'name' => 'RSS 2.0 Index',
'type' => 'index',
'rebuild_me' => '1'
},
I found a site that helped me decipher the code.
To add modules to every new weblog, find the place in the code that looks like
{ 'type' => 'index',
'name' => 'Site JavaScript',
'outfile' => 'mt-site.js',
},
];
and add the entries here for all the modules you want to show up when a new blog is created. So if you have created two modules banner_module.tmpl and sidebar_module.tmpl then the code will look like this.
{ 'type' => 'index',
'name' => 'Site JavaScript',
'outfile' => 'mt-site.js',
},
{ 'type' => 'custom',
'name' => 'Banner Module'
},
{ 'type' => 'custom',
'name' => 'Sidebar Module'
},
];
This solution is a good way to get things in sync with one another to start with. If you don’t give users the ability to change templates on the blog then they won’t be able to get the templates out of sync. The only problems is if you want to do a drastic redesign of all your blogs then you will need to update the template files individually. If you have a few blogs then this probably isn’t too troublesome. You would just edit the templates individually in each of the blogs. However, f you have many blogs then this is a larger issue and you should look into how to use “linked template” which allow you to have your template linked to a file. The idea is you update that file and all the linked templates are updated. I’m working on getting linked templates and the tricks I’ve demonstrated here to work together because in the default-templates.pl you can tell the system to use a linked template when a new blog is created. I haven’t quite figured some path issues with this system yet though. I am guessing that I shouldn’t have problems getting it to work if I spend a little more time. Look a future post on using linked templates to maintain multiple blogs with a unified look with scaleable redesign capablities!


[...] Library Web Chic by Karen A. Coombs. Feed Cool recent post: Tweaking Movable Type [...]
I couldn’t understand some parts of this article Tweaking Movable Type, but I guess I just need to check some more resources regarding this, because it sounds interesting.