2. What is CTools?
• CTools = Chaos Tool Suite
• A contrib project on drupal.org
• Developer APIs and Tools
• Page Manager
• drupal.org/project/ctools
3. What is a CTools
plugin?
• A plugin is way for a module to allow
another module or theme to implement a
piece of functionality
• Useful when you want to add or alter
existing features of a module.
• Types of plugins include contexts,
content types, layouts, and style
4. Style Plugins
• With a Style Plugin, define:
• a settings form
• how to render settings in a template
5. Where do I use it?
• In the Panels interface,
click on gear of pane
and select “Style”
• In Panelizer or
Panopoly, click the
Paintbrush icon
Panopoly Example
6. Demo
• Weber County Library in Ogden, UT
• Panopoly distro, Panels IPE (In-Place Editor)
• Live Preview of panel pane styles
7. Overview of steps
• Create a custom module
• Tell CTools about our plugin files
• Define our $plugin array
• Define our theme and form hooks
• Create our template file and make use
of returned values
11. $plugin gotchas
• Define $plugin array inside our .inc but
outside any function
• CTools knows to look for $plugin because
we told it to in:
hook_ctools_plugin_directory()
13. ‘render pane’
• corresponds to the theme function that
renders the pane, without “theme_”
• If the theme function is named
theme_panesandblocks_render_pane
then the value for ‘render pane’ is
‘panesandblocks_render_pane’
15. ‘region pane’
• corresponds to the theme function that
renders the region, without “theme_”
• If the theme function is named
theme_panesandblocks_render_region
then the value for ‘render region’ is
‘panesandblocks_render_region’
16. ‘pane settings form’
• The full name of the function that returns
the settings form. For example:
panesandblocks_settings_form
• The corresponding function:
function panesandblocks_settings_form
($style_settings)
• Use Form API to build form components.
Set default values using $style_settings
17. ‘hook theme’
• Defines theme functions and variables for
pane and region
• Pane and Region will each have their own
arrays of hook theme information
• Array key = the first parameter of theme()
returned in the corresponding theme_
function
21. vars in template files
• Whatever variables I listed in $plugin’s
‘hook theme’ are passed into the theme
function which make these values available
in my template files
• $content and $settings seem to be the two
preferred choices for variables in hook
theme
30. Troubleshooting tips
• Add a css file through drupal_add_css at
the top of your template file to get the
preview working right away
• Check all instances of panel panes to make
sure they are rendering correctly, as this
template file will override the panels-
pane.tpl.php.
• Add logic to theme function as needed