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). – kiamlaluno Apr 6 '13 at 23:19

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.

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

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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