In one of our blogs we have already touched upon the theme of creation plugins for Panels module, which can be implemented using Ctools. This time we will focus on adding one’s own context - this is another functionality provided by Chaos tool suite.
In Panels the term “context’ refers to a kind of wrapper around any meaningful object. The following contexts are embedded in the Panel module by default:
- Comment;
- File;
- Node;
- Node add form;
- Node edit form;
- String;
- Taxonomy term;
- Taxonomy vocabulary;
- Token, User;
- User edit form.
The list itself is not short but sometimes this is not enough. So there is a mechanism helping a Drupal Developer to add the needed element to the panel. As you can see above there is a context called 'Node add form' but there is nothing like this for the terms of taxonomy. So in this case we’ll describe a plugin that will add a form which allows to create the terms for any panel.
Similarly to other ctools plugins we need to write the following function:hook_ctools_plugin_directory():
/** * Implements hook_ctools_plugin_directory(). */ function context_example_ctools_plugin_directory($module, $plugin) { if ($module == 'ctools' && !empty($plugin)) { return "plugins/{$plugin}"; } }