The CTools pluggable content system provides various pieces of content as discrete bits of data that can be added to other applications, such as Panels or Dashboard via the UI. Whatever the content is added to stores the configuration for that individual piece of content, and provides this to the content.
Each content type plugin will be contained in a .inc file, with subsidiary files, if necessary, in or near the same directory. Each content type consists of some information and one or more subtypes, which all use the same renderer. Subtypes are considered to be instances of the type. For example, the 'views' content type would have each view in the system as a subtype. Many content types will have exactly one subtype.
For the purposes of selecting content from the UI, each content subtype will have the following information:
A short description
A category [Do we want to add hierarchy categories? Do we want category to be more than just a string?]
An icon [do we want multiple icons? This becomes a hefty requirement]
Each piece of content provides one or more configuration forms, if necessary, and the system that includes the content will handle the data storage. These forms can be provided in sequence as wizards or as extra forms that can be accessed through advanced administration.
The plugin for a content type should contain:
For use on the content permissions screen.
Either an array of content type definitions, or a callback that will return content type definitions. This callback will get the plugin definition as an argument.
[Optional] Provide a single content type definition. This is only necessary if content types might be intensive.
The callback to render the content. Parameters:
The name of the subtype being rendered. NOT the loaded subtype data.
The stored configuration for the content.
Any arguments passed.
An array of contexts requested by the required contexts and assigned by the configuration step.
Any 'incoming content' if this is a wrapper.
A callback to provide the administrative title. If it is not a function, then it will be counted as a string to use as the admin title.
A callback to provide administrative information about the content, to be displayed when manipulating the content. It should contain a summary of configuration.
Either a single form ID or an array of forms *keyed* by form ID with the value to be used as the title of the form. %title me be used as a placeholder for the administrative title if necessary.
'ctools_example_content_form_second' => t('Configure first form'),
'ctools_example_content_form_first' => t('Configure second form'),
The first form will always have required configuration added to it. These forms are normal FAPI forms, but you do not need to provide buttons, these will be added by the form wizard.
[Optional] If different from the edit forms, provide them here in the same manner. Also may be set to FALSE to not have an add form.
A file or array of CSS files that are necessary for the content.
A file or array of CSS files that are necessary for the forms.
An array of form information to handle extra administrative forms.
no title override
Set to TRUE if the title cannot be overridden.
Set to TRUE if this content provides exactly one subtype.
Set to true if for some reason this content needs to render after other content. This is primarily used for forms to ensure that render order is correct.
TODO: many of the above callbacks can be assumed based upon patterns: modulename + '_' + name + '_' + function. i.e, render, admin_title, admin_info, etc.
TODO: Some kind of simple access control to easily filter out content.
The subtype definition should contain:
The title of the subtype.
The icon to display for the subtype.
The path for the icon if it is not in the same directory as the plugin.
The short description of the subtype, to be used when selecting it in the UI.
Either a text string for the category, or an array of the text string followed by the category weight.
required context [Optional]
Either a ctools_context_required or ctools_context_optional or array of contexts for this content. If omitted, no contexts are used.
create content access [Optional]
An optional callback to determine if a user can access this subtype. The callback will receive two arguments, the type and subtype.
Rendered content is a little more than just HTML.
The safe to render title of the content.
The safe to render HTML content.
An array of links associated with the content suitable for theme('links').
An optional 'more' link (destination only)
Administrative links associated with the content, suitable for theme('links').
An array of feed icons or links associated with the content. Each member of the array is rendered HTML.
The content type.
The content subtype. These two may be used together as module-delta for block style rendering.
Todo after implementations are updated to new version.