Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Building Custom cTools Plugins in Drupal 7
Oct 05, 2015 @ 17:46:27

The SitePoint PHP blog has a tutorial posted showing you how to build custom cTools in Drupal that will integrate with the widely used cTools tool set.

cTools is one of those critical Drupal 7 modules many others depend on. It provides a lot of APIs and functionality that makes life easier when developing modules. Views and Panels are just two examples of such powerhouses that depend on it. [...] In this article, we are going to take a look at cTools plugins, especially how we can create our very own. After a brief introduction, we will immediately go hands on with a custom module that will use the cTools plugins to make defining Drupal blocks nicer (more in tune to how we define them in Drupal 8).

He starts by briefly introducing the cTools functionality and different types of plugins included in common use. He then moves on to the "block_plugin" handling and the custom functionality you'll be walked through - a plugin encapsulating a block and its related logic. He starts by defining the plugin type with a function the cTools can locate and the code it should contain. From there the code needed to turn a block plugin into a "Drupal block" is added including a prefix to "namespace" them out. Finally the view handling is implemented and a helper function is created to load the plugin. He then shows how to define one of the block plugins complete with a title, markup and type.

tagged: custom ctool plugins drupal block tutorial

Link: http://www.sitepoint.com/building-custom-ctools-plugins-in-drupal-7/


Trending Topics: