Panel panes can be configured to appear when PHP code evaluates TRUE.
For example, a pane displaying the field(s) for a node may only make sense when that field actually has values.
Using the $contexts variable available to content pane visibility settings, one can evaluate such a condition in PHP.
- Add a new rule
- Inspect the $contexts variable
While the PHP code must ultimately return a boolean value, temporarily output the contents of our $contexts variable using drupal_set_message():
Visit your Panels page and you will see the output of the entire $contexts variable -- a variety of nested objects and arrays pertaining to the page.
- Evaluate your condition(s)
After finding the $contexts properties or element(s), return a boolean value (optionally using the negation (NOT) option instead of a PHP operator):
In this example, the panel pane will only appear when the specified condition is met--when the array defining the node's file_field property (array) is not empty.