The Movable Type User Manual

NOTE: This documentation is for Movable Type 3.2. If you are using a newer version, please see the documentation for Movable type 3.3x or Movable Type Enterprise.

« Creating an Alternate Archive Template | Up | Displaying Weblog Data »

Chapter 3: Templates and Layout

Reusing Template Markup with Modules

Problem

You want to reuse a piece of markup or text.

Solution

Create a template module for reuse where necessary.

Discussion

Template modules are found in your blog's template listing screen under the Modules tab. From there you can manage all existing template modules and create new ones.

Template Modules allows you to keep all common markup in one area so that modifications can be made from one place. Modules can contain bits of template tags, text, and other markup that are never directly output as a page. Instead they can be arbitrarily included into any other template, as many times as needed.

For instance, you could create a template module named "Copyright" as such:

 <p>Copyright &copy; 2002-2005. All Rights Reserved.</p>

This module is quite simple and could have easily contained any amount of MT template tags or even other modules if appropriate. With the "Copyright" module saved you could add template markup to include it in every one of the weblog's templates. To include a module use MTInclude with the module attribute.

 <$MTInclude module="Copyright"$>

With this template tag in place, the contents of the Copyright module would be inserted at this point. If our module contained MT template markup, it would have been processed as if it were part of the template in which it was included.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or question. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.