2

I'm trying to add a PHP field to a view, but I cannot see how to activate it. Do I need a module?

I'm already using / viewing:

Global: View result counter
Global: Math expression (Math expression)
Global: Custom text (Custom text)

I'd like to know how I could add:

Global: PHP field

I think it exists because of Global:PHP field with SQL in output code.

2 Answers 2

5

Just install the Views PHP module and you can now add a "Global: PHP field" to your views that can include PHP code. Quote from its project page:

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.

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.

2

You'll need to provide more details. Without understanding your question the link to the "Views PHP" module does in fact

"allow administrators to add fields, filters and sorts to views which use PHP code."

The trick is that you'll still need to understand the Views system to know what to add with your code. Note the authour of the module advises

"it is highly advisable to use regular handlers and plugins when available (or even to create one yourself)."

1
  • Updated with more info, hope it helps. Commented Sep 25, 2011 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.