Views PHP

Installs: 
44,497
Open Bugs: 
79
Development Status: 
Seeking co-maintainer(s)
Maintenance fixes only

Seeking co-maintainers!

This 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.

This is the successor of Views Custom Field for both D6 and D7. The D6 version supports both Views 2 and Views 3.

Note

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.

Alternatives

An alternative to this module is Computed field. It lets you add an actual field to your entities where you specify the PHP code you'd like to run. You can store the computed result in the database or have it run on the fly when viewed directly or through Views. It also lets you implement hooks in your own modules which hold your computation code so it can be version controlled. Views PHP doesn't have this ability, but there's a feature request for this over at #1326780: Provide function templates for code to use instead of text areas
.

To alter SQL queries you could use modules like Views Raw SQL and Views Custom Conditions.

Available handlers

Area
An (header/footer/empty) area which output is constructed by the administrator using PHP.
Field
A field which value and/or output is constructed by the administrator using PHP. Click-sort is also available and accepts a number of predefined sort algorithms or custom PHP.
Filter
A filter based on custom PHP code; use PHP to filter out any row.
Sort
A sort based on custom PHP code; use PHP to sort the result of a view.

Available plugins

Access
Access control based on custom PHP code; use PHP to determine whether a user has access to a view.
Cache
Cache control based on custom PHP code; use PHP to determine whether a view's (result/output) cache is still fresh.
Releases: 
7.x-1.x-dev
6.x-1.x-dev
Release Dates: 
10/19/2013
10/19/2013