One can easily concatenate fields in views with a re-write rule.. However, I have two fields, age_range and warning, the second of which may be empty. I want to display them like this:

Ages 2+

Ages 4-10, choking hazard

If warning is empty, I don't want to show a comma. If I make a rewrite rule like this

[age_range], [warning]

Then I get a result like this:

Ages 2+,

Ages 4-10, choking hazard

How can I avoid a trailing comma?

1 Answer 1


I would actually suggest doing the reverse of the answered question that you linked to for just the scenario you are describing.

  1. Add Field B and Exclude it from the display.
  2. In the Rewrite results area of Field B, enable Rewrite the output of this field.
  3. On Field B, add a comma and the token for the raw value: ', [field-b]'
  4. Under 'No Results Behavior' for Field B, make sure that 'Hide if empty' and 'Hide rewriting if empty' are checked.
  5. Then rewrite your Field A to include Field B: '[field-a][field-b]'. Make sure there is no space, so that the comma will immediately follow Field A if Field B has a value.

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.