Details
If you are familiar with the Melody/Endevver approach to theming with Movable Type 4, you are also likely familiar with the Theme Manager plugin. Theme Manager did a lot of great things to make themes more manageable on Movable Type 4, however Movable Type 5 introduced a more comprehensive theming system, largely negating the need for Theme Manager’s capabilities.
But, there are still some things Theme Manager does that we missed in MT5 — most notably, setting Template Module and Widget caching options automatically and the ability to update Custom Fields. (Theming in MT5 supports installing Custom Fields, but not updating them.)
Installation
To install this plugin follow the instructions found here:
http://tinyurl.com/easy-plugin-install
Use
Specify your Custom Fields and caching options in YAML. Note that Theme Assistant currently only looks at template_sets
(the MT4 way of theming) to find these values. Some abbreviated example YAML:
templatesets: myawesometheme: label: ‘My Awesome Theme’ templates: module: myhelpermodule: label: ‘Cached Helper Module’ cache: expiretype: 1 expireinterval: 60 includewithssi: 1 fields: entryextratextfield: label: ‘Extra Text Field’ description: ‘This is a text custom field.’ default: ‘Replace this default text with any value.’ required: 1 obj_type: entry type: text tag: EntryExtraTextField
Set Caching and Include Options
Caching options can also be specified for Template Modules and Widgets with the following keys (if you’ve used the UI to set caching, these options should all be familiar). Module Caching must be enabled, though Theme Assistant will automatically enable caching if it’s not already set.
cache
- the parent key to the below optionsexpire_type
-- 0: No caching (the default method)
- 1: time-based expiration (“Expire after x minutes”)
- 2: event-based expiration (“Expire upon creation or modification of object”)
expire_interval
- This key is used only ifexpire_type: 1
is used. Specify a time to expire in minutes.expire_event
- This key is used only ifexpire_type: 2
is used. Specify a valid object to cause expiration. Valid objects are as follows:- asset
- author
- category
- comment
- entry
- folder
- page
- tbping
Another import aspect to caching is using “includes.” The key
include_with_ssi
allows the specified module or widget to be included as an
external file, saving server resources and making it easy to keep content
updated site-wide. Possible values are 1
and 0
(the default). Within the
UI, this option corresponds to the “Process as [SSI method] include” option
found when editing Template Modules and Widgets.
Server Side Includes must be enabled at the blog level (enable this in Settings > General).
Install and Update Custom Fields
Many sites require the use of the Movable Type Commercial Pack’s Custom Fields
(part of MT Pro). If fields are specified in your theme’s config.yaml
they
can be automatically created when you apply your theme.
The following example shows how to add a text custom field for Entries to the theme we’re building.
template_sets:
my_awesome_theme:
label: 'My Awesome Theme'
fields:
entry_extra_text_field:
label: 'Extra Text Field'
description: 'This is a text custom field.'
default: 'Replace this default text with any value.'
required: 1
obj_type: entry
type: text
tag: EntryExtraTextField
scope: blog
Custom Field definitions appear beneath the key fields
.
The key entry_extra_text_field
is the basename of this field.
The description
, required
, default
, and scope
keys are optional.
The key obj_type
is the type of object this field targets; entry
, page
,
category
, folder
, and author
are valid. These correlate to the System
Object field in the GUI, of course.
The key type
is the type of field to be created. Note that this is the key
name of the field, not the public-facing name you see in the GUI. The
Commercial Pack defines the following types of fields with these keys:
- Text:
text
- Multi-Line Text:
textarea
- Checkbox:
checkbox
- URL:
url
- Date and Time:
datetime
- Drop Down Menu:
select
- Radio Buttons:
radio
- Embed Object:
embed
- Post Type:
post_type
- Asset:
asset
- Audio:
asset.audio
- Image:
asset.image
- Video:
asset.video
If you have other custom fields available they may also be specified in your
theme’s config.yaml
; you just need to specify the key correctly.
To create a system-level custom field (necessary is you use the author
object type), include the scope
key:
template_sets:
my_awesome_theme:
label: 'My Awesome Theme'
fields:
author_bio:
label: 'Author Bio'
obj_type: author
type: textarea
tag: AuthorBio
scope: system
Compatibility
Movable Type versions: 5.05.15.26.0 Verified
License
Perl Artistic
Dan is an engineering creative and uses his vast knowledge of the web to solve unique client problems with specialized solutions. Complex or straightforward, his focus is to find the most efficient, functional, elegant, and stable solutions for each project. 10 years in web engineering and 14 more in the print publishing industry give him a special insight to the needs, restrictions, and workflows of content publishers, both traditional and new media. Dan is an active Movable Type community member who has written and contributed to countless plugins including some of the most popular: More Custom Fields, Poll Position, and Asset Image Quality.