Advanced Information and Use Cases

Ctools Plugin array

Every ctools plugin is defined by an array – so if you're building your own content type, arguments, contexts etc. you'll find yourself defining this array at the beginning of your plugin

$plugin = array(

'key' => value,

}

There are multiple values and variables and so this is just the beginning of the documentation of ones we have found

Key

Values explained

Plugin Type

E.g.

title

Title of the plugin – use t('XXXX') to translate

t('My title')

description

Description of the plugin – use t('xxx') to translate

t('My desc')

icon

The related icon shown to the user (*.png file)

content_type

form_icon.png

category

The category shown to the user

content_type

render callback

The callback function to use in order to render this content type. See content.inc->ctools_content_render.

content_type

content_types

The constructor function for the content type

content_type

defaults

The default context.

array()

edit form

The configuration form function

content_type

all contexts

TRUE or FALSE. Tells ctools if all contexts should be passed to this plugin. See content.inc->ctools_content_select_context

content_type

TRUE

required context

Tells ctools which contexts are required by this plugin. Should be a ctools_required_context object

content_type

new ctools_context_required(t('Term'), array('term', 'terms'))

This creates a required context called Term – with an array of context types to match (term, terms)

render last

TRUE or FALSE

single

TRUE or FALSE

Use Case: Putting administration forms into Panels

Whilst developing a new module which had quite a few administration forms for it (there are a bunch of our own tables we've added to the site install), we wondered if there was a way to create the entire administration interface via panels.

In order to do that, we needed to get all the administration forms we created into a form acceptable to panels – which could have meant creating a content type for each one. However, we found another more generic way of doing that. By exposing a hook which looked for definitions of all forms which could be shown in a panel, we were able to create just one form content type which can be inserted into a panel.