Skip to main content
3 of 4
added 569 characters in body
neha
  • 662
  • 2
  • 10
  • 23

How do I create a custom plugin?

Basically, I want to port a custom ctools plugin created for content type from Drupal 7 to Drupal 8. This is the code I want to port.

function my_module_ctools_plugin_directory($module, $plugin) {
  if (($module == 'ctools') && ($plugin == 'content_types')) {
    return 'plugins/content_types';
  }
}

In my_module/plugins/content_types/my_module.inc file i have following code:

/**
 * Plugin array() of ctools plugin.
 */
$plugin = array(
  'title' => t('My Module'),
  'single' => TRUE,
  'content_types' => array('my_module_custom_content_type'),
  'render callback' => 'my_module_render',
  'required context' => new ctools_context_required(t('Node'), 'node'),
  'edit form' => 'my_module_settings_form',
  'edit form validation' => 'my_module_settings_form_submit',
  'category' => 'Widgets',
);

How do I port the plugin to Drupal 8?

neha
  • 662
  • 2
  • 10
  • 23