Advertising sustains the DA. Ads are hidden for members. Join today

Contributed modules for Drupal 7

Views PHP

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

The Views PHP module allows the admin account (user 1) to add fields, filters and sorts to views which use PHP code. It also supports additional accounts when the core PHP Filter module is enabled.

While this module allows you to directly use PHP inside views which may be useful for quick and easy solutions, it is highly advisable to use regular handlers and plugins when available (or even to create one yourself). Take note that filtering and sorting a view using PHP always has a considerable perfomance impact.

Usage

How to use PHP to modify your view from the Views UI.

Output code

The Views PHP field contains a section labelled Output code where you can create output to be displayed by the field.

Value code

How to use the value code text-area.

Guide maintainers

fizk's picture