I created a view, and I need to put some PHP or JavaScript in it. I would like to add some if conditions.

Is this possible?

  • Hello, and welcome to Drupal Answers. The answer to your question is yes, although that doesn't help you much. May you expand your question, and explain what you need to achieve? That would make the answer more detailed, and useful to you (and future readers).
    – apaderno
    Apr 6, 2013 at 23:19

3 Answers 3


It kind a depends of where in your view you want to use php. But if it is in fields there are two options:

  1. Views Custom Field (d6 only)
  2. Views PHP - in dev though

Yes, it is possible.

If you want to use PHP in views header, you can go to configure header, select "Global: Text area" and have to change text format to PHP code; you have to first install the PHP filter module.

If you want to use PHP in view fields, you can use the Computed field module.

If you want to use PHP in a view itself, you have to customize your views and then you can easily add PHP code to it.


in the field of view you can add Global PHP field
you can fiend this field in the header or in footer

Your Answer

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

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