ExpressionEngine® 3 User Guide

Legacy Documentation

You are using the documentation for version 3.5.17. Go here for the latest version or check here for your available upgrades to the latest version.

Design Controller Extension Hooks

template_types

template_types()

Add template types to ExpressionEngine’s default set. In the Output library specifically, it is useful to return the appropriate content type header for the template type.

How it’s called:

$template_types = $EE->extensions->call('template_types');
Returns:The custom templates array (see below)
Return type:Array

This hook must append a key to the $last_call array in the following format:

$custom_templates = ee()->extensions->last_call;

$custom_templates['ical'] = array(             // Short name for database
    'template_name'           => 'iCal Feed',  // Display name for Template Type dropdown
    'template_file_extension' => '.ics',       // File extension for saving templates as files
    'template_headers'        => array(        // Custom headers for file type
        'Content-Type: text/ical',
        'Content-Disposition: attachment; filename="event.ics"'
    )
);

Note

It is good practice to clean up the templates table and remove your custom template type from templates using it upon extension uninstallation.

New in version 2.4.0.