<$mt:Include$>
Includes the contents of a template module or external file into the current template where is it used.
<$mt:Include module="Sidebar"$>
Attributes
Note: One of the following attributes is required and not more than one may be used:
blog_id
Used to include a template from another blog in the system. Use in conjunction with the module, widget, or identifier attributes.
<$mt:Include module="Sidebar" blog_id="1"$>
Using a value of “0” will include a global template module, same as if the global attribute is used.
cache
Enables caching of the contents of the include. Used in conjunction with the ‘cache_key’ attribute. Suitable for module, widget, or identifier includes. Default value is “0”.
<mt:SetVarBlock name="cache_key"><mt:EntryCategory></mt:SetVarBlock>
<$mt:Include widget="Related Entries" key="$cache_key" ttl="3600" cache="1"$>
cache_key
Unique cache id use the template module. Used in conjunction with the ‘cache’ attribute. Suitable for module, widget, or identifier includes.
See cache for example.
file
NOTE: In Movable Type 5.13, 5.07, 4.38, and later versions, this attribute is disabled in default settings. You can enable it by specifying AllowFileInclude configuration directive.
The path to an external file on the system. The path can be absolute or relative to the Local Site Path. This file is included at the time your page is built. It should not be confused with dynamic server side includes like that found in PHP.
<$mt:Include file="/var/www/html/some-fragment.html"$>
global
Forces an Include of a globally defined template even if the template is also available in the blog currently in context. Default value is “0”.
<$mt:Include module="Sidebar" global="1"$>
(For module, widget, and identifier inc. Doesn’t have any effect on including file attribute.)
parent
Forces an Include of a template in the parent website. Default value is “0”.
<$mt:Include module="Sidebar" parent="1"$>
(For module, widget, and identifier inc. Doesn’t have any effect on including file attribute.)
identifier
For selecting Index templates by their unique identifier.
<$mt:Include identifier="main_index"$>
key
Alias of cache_key.
module
The name of a template module in the current blog.
<$mt:Include module="Sidebar"$>
name
For application template use: identifies an application template by filename to load.
ssi
Causes the include to be handled as a server-side include. Default value is “0”. If “1” is specified instead, mt:Include tag generates a SSI file with the format which you set in the blog settings ( [Settings] > [General] > Module Settings ).
For example if you have set it to “PHP Includes”
<$mt:Include module="Tag Cloud" ssi="1"$>
This tag outputs a php include tag:
<?php include("/path/to/blog/includes_c/tag_cloud.php") ?>
Suitable for module, widget, and identifier includes.
ttl
Specifies the lifetime in seconds of a cached template module. Suitable for module, widget or identifier includes.
See cache for example.
widget
The name of the widget in the current blog to include.
<$mt:Include widget="Search Box"$>
Examples
Also, other attributes given to this tag are locally assigned as variables when invoking the include template.
Variables in Attribute Values
Variables may be passed into the values. If various template modules were created for each category (such as “Foo Sidebar” for category “Foo” and “Bar Sidebar” for category “Bar”) then you could include the templates like this on an Entry archive template. This example also includes a default template if there is no category:
<mt:SetVarBlock name="sidebar_template"><$mt:EntryCategory$> Sidebar</mt:SetVarBlock>
<mt:If tag="EntryCategory">
<$mt:Include module="$sidebar_template"$>
<mt:Else>
<$mt:Include module="No Category Sidebar"$>
</mt:If>
Passing Parameters
Parameters may be defined before including a template or may be passed to the included template module as custom attribute. One variable (section_subtitle) is defined using the Var tag and the second variable (section_title) is defined as an attribute of the mt:include tag:
<$mt:Var name="section_subtitle" value="I am the subtitle"$>
<$mt:Include module="Section Header" section_title="Elsewhere"$>
The “Section Header” template module uses the values set by the include:
<h1><$mt:Var name="section_title" _default="Default Title Here"$></h1>
<h2><$mt:Var name="section_subtitle" _default="Default Subtitle Here"$></h2>