I am building a website using views and the answer module.

In my view, I add "Content: Answer Count" which is the number of answers.

I want to be able to rewrite the following output:
(1 Answer)
(2 Answers)
(3 Answers)

I know how to output "(no answers yet)" when the count=0.
But, how can I differentiate between singular and plural and output "Answer" or Answers" according to the count?

3 Answers 3


Drupal views provides a singular/plural option, if the field value is an integer type. In your case, if its not available in Field settings try using views_php contrib module.

This module will allow you to add a field in views with php code that will executed on the fly. You can get existing values of row data inside php from $data variable. Now you can get your output based on the singular/plural in php.

But it is suggested to check the field settings properly if same option is available.


I am not sure you doing it in a custom manner, but there is format_plural() which is used for the same problem you have stated above. By default, almost every contributed and core module uses it, but in case if they are not, you will have to override them.


use a global field (math), which will give you the option of the plural formatter

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.