Home
A blog about web development and Drupal.

panels

August 19, 2015

Building a Configuration Form for a Custom Panels Plugin

In my previous post, we built a custom Panels plugin that shows a node status icon to indicate whether the node is published or unpublished. This time around, we will enhance that plugin by introducing a configuration form. For the sake of demonstration, we will add a setting that lets the user choose when they want the show the status icon: only when the node is unpublished, or always. As one might expect, we will need to use Drupal's From API to define the configuration options. First, we need to tell Panels which function to call when it shows the configuration form. This can be done by…

July 30, 2015

Showing a Node Status Icon Using a Custom Panels Plugin

We often use Panels to build node page layouts, because it enables a vast range of options to show content in various sections of the page. In addition, you can develop a custom plugin for Panels, which brings ultimate flexibility. I took that route when I needed to display an icon next to the node’s title to indicate whether it is published or not. The Panels module relies on the Ctools plugin API, so in order to add our custom plugin to Panels, we need to implement hook\ctools\plugin\directory(). This will tell Ctools where it can find our plugins. This hook gets called multiple times, but…