I want to add a virtual field to a "node", its content should be computed from other fields of this node (with the module of the same name or with a hook) AND it must be usable by Views filter and sorting.

Is this possible (using modules or PHP code) ?

2 Answers 2


I found answser on this site: http://barcelona2012.drupaldays.org/sessions/displaying-external-data-fly-views-and-ctools

This simple module give a clear example on how to expose external data (webservice) to a views.


Use the computed field module. The advantage is that the field is saved in the database and can be manipulated by views without performance overhead. The field's value is updated whenever the field is saved.

The code for the computed field should preferrably be placed in your module, not in your database. Use the computed field hook - here is a nice (tutorial).

Here are some code examples.

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.